JNI System.LoadLibrary failed on Cocoa dylib

余生颓废 提交于 2019-12-12 06:05:39

问题


following JNI guidelines, I created a dylib (in Objective-C) using Xcode and expected to load it in my Java project, like the following does,

public class Main {
private native void done();
    public static void main(String[] args) {
        New Main().done();
}

static {
    System.loadLibrary("Test");
}

public Main() {
    super();
}

and I am getting the following runtime error -

Exception in thread "main" java.lang.UnsatisfiedLinkError: no Test in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1754)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at Main.<clinit>(Main.java:27)

How could I get this fixed?


回答1:


Tried using the System.load with full path to the library and it worked.



来源:https://stackoverflow.com/questions/6255710/jni-system-loadlibrary-failed-on-cocoa-dylib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!