javamacosjava-native-interfaceunsatisfiedlinkerror

JNI UnsatisfiedLinkError .jnilib not fond


I am having some problems with linking a jnilib in java. I receive Exception in thread "main" java.lang.UnsatisfiedLinkError: no ***.jnlib in java.library.path. Through my research I found that this could be caused by java not knowing were the file was. So, I told it that it was in the Mac folder. I also added the file to every other folder in the project. None of this helped at all. The project is cross platform so I tried it on windows the dll's loaded just fine when I told java to look in the windows folder. I do not understand why this would work in windows and not on a Mac. Any thoughts or ideas will be welcome.

The exception output is:

    Exception in thread "main" java.lang.UnsatisfiedLinkError: no libhidapi-jni-64.jnilib in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758) 
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1045)
        at webstart.OmronIO.<init>(OmronIO.java:30)
        at webstart.Omron.main(Omron.java:13) 

The java.library.path is: /Volumes/UNTITLED/javahidapi/mac.

The path to the jinlib is : /Volumes/UNTITLED/javahidapi/mac.


Solution

  • On OSX, the environment variable DYLD_LIBRARY_PATH is used to find shared libraries (including .jnilib). That variable is what is used to initialize java.library.path.

    If you output the value of java.library.path at the point where you attempt System.loadLibrary(), you will see the list of directories searched for the library you are attempting to load.

    EDIT

    See also http://create-lab-commons.googlecode.com/svn-history/r222/trunk/java/lib/HIDAPI/README.txt, which appears to apply to the specific library you're attempting to load (hidapi), and the way you're attempting to load it (webstart).