Search code examples
javanetbeansjava-native-interfaceunsatisfiedlinkerror

java.lang.UnsatisfiedLinkError: Can't load AMD 64-bit .dll on a IA 32-bit platform


Encountered this java.lang.UnsatisfiedLinkError: Can't load AMD 64-bit .dll on a IA 32-bit platform when trying to run java file in netbeans ide. Not sure where to begin for debugging and fixing code.

Source code follows:

package demojni;
public class Main {
   static {
      System.load("C:\\Users\\Nicholas1\\Documents\\NetBeansProjects\\DemoJNI_Lib\\dist\\DemoJNI_Lib.dll"); // Load native library at runtime
                                   // hello.dll (Windows) or libhello.so (Unixes)
   }

   // Declare a native method sayHello() that receives nothing and returns void


   // Test Driver
   public static void main(String[] args) {
      new Main().sayHelloWorld();  // invoke the native method
   }
   private native void sayHelloWorld();
}

Solution

  • The Dll is compiled for 64 bit ( amd64 or x86_64 ) platform/cpu architecture while your windows OS/JVM/JRE installation is/are 32 bit.

    Either get a 32 bit version of the dll or upgrade your working environment ( either OS or JVM/JRE installation