java JNI error java.lang.UnsatisfiedLinkError:

 ̄綄美尐妖づ 提交于 2020-01-03 13:39:37

问题


java -Djava.library.path=. TestJNI
>>>>

Exception in thread "main" java.lang.UnsatisfiedLinkError: TestJNI.calibrate([D[DII)[D
 at TestJNI.calibrate(Native Method)
 at TestJNI.main(TestJNI.java:61)

I know the library is getting loaded otherwise the error says cant find calibrate library. what does the above error mean?

EDIT

this is my implementation-

JNIEXPORT jdoubleArray JNICALL Java_TestJNI_cailbrate (JNIEnv * env, jobject jobj, jdoubleArray rtt, jdoubleArray distance ,jint activecount,jint passivecount) {
jdoubleArray jresult = (*env)->NewDoubleArray(env,3);
 .......
return jresult;
}

are the parameters declared correctly?


回答1:


This message means that Java is looking for a native method that looks like the Java method

double[] calibrate(double[], double[], int, int)

If you have generated your header files correctly, and built the library, this most likely means you are missing the implementation of that method.

Some things that come to mind:

  • Did you rebuild the library after you implemented the method?
  • Did you happen to change the interface of the Java method after you built the library?



回答2:


Another cause of this cryptic error is when you import the incorrect <jni.h> file. For instance, if you are compiling against x86 but point your includes path to the x64 flavor of the header.



来源:https://stackoverflow.com/questions/4526198/java-jni-error-java-lang-unsatisfiedlinkerror

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