1
votes
DLL INSTANCE = (DLL) Native.loadLibrary(Settings.getSingletonInstance().getProperty("default.ergoPointer.path"), DLL.class);

I store the dll path in settings file. When i take output of

Settings.getSingletonInstance().getProperty("default.ergoPointer.path"

here : C:\Users\Argenit\Desktop\aaa\dll\ErgoPointer_64_Bit.dll

Error part :

java.lang.UnsatisfiedLinkError: Unable to load library 'C:\Users\Argenit\Desktop\aaa\dll\ErgoPointer_64_Bit.dll': Native library (win32-x86-64/C:\Users\Argenit\Desktop\aaa\dll\ErgoPointer_64_Bit.dll) not found in resource path ([file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/bin/, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/resources/, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/fits.jar, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/json.jar, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/junit-4.8.2.jar, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/kdu_jni.jar, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/log4j-1.2.16.jar, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/JNA/jna-4.1.0.jar, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/JNA/jna-platform-4.1.0.jar, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/ini4j-0.5.4.jar, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/JNA/, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/gluegen-rt.jar, file:/C:/Users/Argenit/Desktop/Pathology_JAVA/Digital_Pathology/lib/jogl.jar])

If i add (dll) as a external class folder in project and write : loadLibrary("ErgoPointer_64_Bit"), it works in this machine but when i take the runnable jar, it couldn' t find ErgoPointer_64_Bit so i want to give absolute path of dll. But it doesn' t work for me.

I also tried :

C:\Users\Argenit\Desktop\aaa\dll\ErgoPointer_64_Bit

dll\ErgoPointer_64_Bit

ErgoPointer_64_Bit

dll\ErgoPointer_64_Bit.dll

ErgoPointer_64_Bit.dll

1

1 Answers

2
votes

Set the system property java.library.path before the call Native.loadLibrary() with just the base name.

System.setProperty("java.library.path", 
            "C:\\Users\\Argenit\\Desktop\\aaa\\dll;" 
              + System.getProperty("java.library.path"));
DLL INSTANCE = (DLL) Native.loadLibrary("ErgoPointer_64_Bit", DLL.class);

You can also set the java.library.path on the command line. eg.

java "-Djava.library.path=C:\Users\Argenit\Desktop\aaa\dll\" -jar somejar.jar