From 4e4606b3d4903ac5d0c33f931f5edb857f8dbd84 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 17 May 2017 19:07:40 +0200 Subject: [PATCH] Allow to specify a library folder to avoid native lib unpacking. On some circumstances you're not allowed to write to the user home or to load code by unpacking it. This commit allows to specify a VM variable called "jssc.library.path" that is the path where JSSC will search for native libraries. --- src/java/jssc/SerialNativeInterface.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/java/jssc/SerialNativeInterface.java b/src/java/jssc/SerialNativeInterface.java index c5264f5e8..32e4ce2be 100644 --- a/src/java/jssc/SerialNativeInterface.java +++ b/src/java/jssc/SerialNativeInterface.java @@ -140,7 +140,12 @@ else if(architecture.equals("arm")) {//since 2.1.0 architecture = "arm" + floatStr; } - libFolderPath = libRootFolder + fileSeparator + ".jssc" + fileSeparator + osName; + String jsscLibPath = System.getProperty("jssc.library.path"); + if (jsscLibPath != null) { + libFolderPath = jsscLibPath; + } else { + libFolderPath = libRootFolder + fileSeparator + ".jssc" + fileSeparator + osName; + } libName = "jSSC-" + libVersion + "_" + architecture; libName = System.mapLibraryName(libName);