我在ubuntu的test.cpp中創建了libcc.so,並且test.cpp的內容與ffmpeg和opencv庫鏈接。在創建libcc.so之後,它將加載到JNItest2.java中。當我在終端運行jar文件時發生錯誤
JNItest2.java:
public class JNItest2 {
public native void helloworld();
static{
String libPath= "/home/sun/workspace/JNItest2/src";
System.setProperty("java.library.path",libPath);
String Path = System.getProperty("java.library.path");
System.out.println("java.library.path=" + Path);
System.loadLibrary("cc");
}
public static void main(String[] args){
new JNItest2().helloworld();
}
}
然而,JNItest2.java可以在Eclipse中運行,導出的jar文件不能在終端中運行。在終端
錯誤消息:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no test in
java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at
java.lang.Runtime.loadLibrary0(Runtime.java:870) at
java.lang.System.loadLibrary(System.java:1122) at JNItest2.<clinit>
(JNItest2.java:23)
有誰幫我解決這個問題呢?
感謝,林秀
決定你的想法。你的源碼是''cc「',但是錯誤信息是'test'。 – EJP