我正在尝试运行Java本机接口程序。当我尝试运行该程序时,使用C:\ Java \ bin \ java JNITest运行时出现错误
Exception in thread "main" java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: JNITest
at java.lang.Runtime.load0(Runtime.java:806)
at java.lang.System.load(System.java:1086)
at JNITest.<clinit>(JNITest.java:5)
我的程序是
public class JNITest {
static{
// System.load("/home/user1/
// JNI_project/mynativelib.so");
System.load("JNITest");
}
// public native void LOSSGREENAMPT(TIMEINTERVAL, STARTINITIALLOSS,double ENDINITIALLOSS,double MOISTUREDEFICIT, double SUCTION,double CONDUCTIVITY, double STARTINFILTRATION,double FINALINFILTRATION, double IMPERVIOUSAREARATIO,int NUMBERPRECIP, double PRECIP(1),double EXCESS(1),int ERRORCODE[4], char ERRORMESSAGE[60],char L_errorMessage[60]);
public static void main(String[] args) {
JNITest test=new JNITest();
//test.greet();
}
}
我的程序有什么问题
最佳答案
System.load(String filename)
需要file参数作为库的绝对路径。因此,如果JNITest.dll的完整路径是C:\JNITest.dll
,则应调用System.load("C:/JNITest.dll")
。