Mac + jni + java

Small background: I have a Java application that needs to talk to third-party hardware on a Mac. They gave me sdk, but this is not in Java. Therefore, I am trying to make jnilib that will act as a bridge between my java application and the SDK.

Problem: I made a small jnilib example that speaks with the SDK, but when I try to use it in my java program, I get the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/john.doe/Desktop/eclipse/workspace/Lesson13_Jni_Smart7/bin/libSmartTest7.jnilib:  Library not loaded: build/Release/SMARTResponseSDK.framework/Versions/A/SMARTResponseSDK  Referenced from: /Users/john.doe/Desktop/eclipse/workspace/Lesson13_Jni_Smart7/bin/libSmartTest7.jnilib      
Reason: image not found
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1827)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1742)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1045)
    at com.learning.lesson13.JniSmart7.<clinit>(JniSmart7.java:6)

From the error it looks like mine is libSmartTest7.jniliblooking for a library SMARTResponseSDK.

What I tried I know where the library SMARTResponseSDKis on my Mac. I tried to copy it to the working folder in eclipse, but I still get the error. I tried to use -DJava.library.path, but I still get the error.

Any ideas for a better approach.

+5
1

JNI, , java.library.path.

JNI, , , , LD_LIBRARY_PATH/DYLD_LIBRARY_PATH, , .

, :

JNI rpath.

0

All Articles