Search code examples
javadlljava-8java-native-interfaceunsatisfiedlinkerror

java.lang.UnsatisfiedLinkError: C:\...\xxx.dll: Can't load this .dll (machine code=0xbd) on a AMD 64-bit platform


I want to load DLL library to work with it but I have a little problem with this message

java.lang.UnsatisfiedLinkError: C:\xx\xx.dll: Can't load this .dll (machine code=0xbd) on a AMD 64-bit platform

and this is the code that i used to load my DLL library

String arch = System.getProperty(ARCH_OS_CONSTANT);
                if (arch.equals("32")) {
                    System.load("C:\\..\\xx.dll");
                } else if (arch.equals("64")) {
                    System.load("C:\\xx\\xx.dll");
                }

and still have the same problem and I hope that I've found a solution thanks


Solution

  • I am guessing that the value of ARCH_OS_CONSTANT is "os.arch" - the standard property name.

    If so, your code is assuming that the value of "os.arch" for Intel/AMD 32 bit will be "32". That's not correct. According to this Q&A, the value will actually be "x86", and for Intel / AMD 64 bit it will be either be "amd-64" or "x86-64".

    There is also a property called "sun.arch.data.model" that can have value "32" or "64". Unfortunately it is not one of the standard properties listed in the javadoc, and some JVMs don't support it.