我有一个在 JBuilder 6 调试器中完美运行的小型测试程序。当我创建一个 .jar 文件并运行它时,我得到一个错误
>java -jar testadll.jar
Start of DLL test
Exception in thread "main" java.lang.UnsatisfiedLinkError: jnidispatch (/com/sun
/jna/win32-x86/jnidispatch.dll) not found in resource path
at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:708)
at com.sun.jna.Native.loadNativeLibrary(Native.java:685)
at com.sun.jna.Native.<clinit>(Native.java:109)
at testadll.TestThisDLL$PenniesLib.<clinit>(TestThisDLL.java:24)
at testadll.TestThisDLL.main(TestThisDLL.java:33)
我搜索了我的驱动器,上面没有 jnidispatch.dll。
该程序是
package testadll;
import com.sun.jna.Library;
import com.sun.jna.Native;
//import com.sun.jna.NativeLong;
import com.sun.jna.Platform;
import com.sun.jna.win32.StdCallLibrary;
//import com.sun.jna.*;
public class TestThisDLL {
public interface PenniesLib extends StdCallLibrary {
PenniesLib INSTANCE = (PenniesLib) Native.loadLibrary(
"PenniesLib", PenniesLib.class);
int a();
}
public static void main( String args[] ) {
System.out.println("Start of DLL test");
//TestDLL t = new TestDLL();
//System.out.println("DLL loaded");
int value = PenniesLib.INSTANCE.a();
System.out.println("DLL response is " + String.valueOf(value));
}
}