Skip to content

Commit dd608e9

Browse files
authored
Merge pull request #4 from OpenBCI/use-absolute-library-paths
Use absolute paths to load libraries
2 parents be14261 + 10f81dc commit dd608e9

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

  • java-package/openbci_gui_helpers/src/main/java/openbci_gui_helpers

java-package/openbci_gui_helpers/src/main/java/openbci_gui_helpers/GUIHelper.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ private interface DllNativeInterface extends Library
4444
}
4545

4646
// need to extract libraries from jar
47-
unpack_from_jar (lib_name);
48-
unpack_from_jar (lib_native_name);
47+
String lib_path = unpack_from_jar (lib_name);
48+
String lib_native_path = unpack_from_jar (lib_native_name);
4949

50-
instance = (DllInterface) Native.loadLibrary (lib_name, DllInterface.class);
51-
instance_native = (DllNativeInterface) Native.loadLibrary (lib_native_name, DllNativeInterface.class);
50+
instance = (DllInterface) Native.load (lib_path, DllInterface.class);
51+
instance_native = (DllNativeInterface) Native.load (lib_native_path, DllNativeInterface.class);
5252
}
5353

54-
private static void unpack_from_jar (String lib_name)
54+
private static String unpack_from_jar (String lib_name)
5555
{
5656
try
5757
{
@@ -60,9 +60,11 @@ private static void unpack_from_jar (String lib_name)
6060
file.delete ();
6161
InputStream link = (GUIHelper.class.getResourceAsStream (lib_name));
6262
Files.copy (link, file.getAbsoluteFile ().toPath ());
63+
return file.getAbsolutePath();
6364
} catch (Exception io)
6465
{
6566
System.err.println ("native library: " + lib_name + " is not found in jar file");
67+
return "";
6668
}
6769
}
6870

0 commit comments

Comments
 (0)