Error executing with JNI
I followed开发者_高级运维 this tutorial http://www.ibm.com/developerworks/java/tutorials/j-jni/section2.html (C implementation) for implementing a simple example of JNI interfacing but I get this error when running the java file:
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\JNI_examples\example2\Sample1.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1728)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at Sample1.main(Sample1.java:10)
I don't know why it's thinking it is AMD 64-bit...
I also tried running with the path of the library: java -Djava.library.path=. Sample1
But that didn't seem to help any...
I run cl a little differently because of different paths, this is what I run:
cl -I"C:\Program Files (x86)\Java\jdk1.6.0_24\include" -I"C:\Program Files (x86)\Java\jdk1.6.0_24\include\win32" -LD Sample1.c -FeSample1.dll
Any clue about what's going on?
Thanks!
Your JVM is probably 32-bit, when you've compiled the DLL for 64-bit. The JVM needs libraries compiled to the same architecture as the JVM, with no exceptions. Change your compilation settings to compile a 32-bit DLL and it should work.
IA-32 stands for Intel Architecture 32-bit, which is x86, while AMD 64 relates to x86-64. Intel ended up licensing the AMD stuff.
精彩评论