Java Native Interface 32 bit dll on 64 bit system
Solution 1:
You'll have to install a 32bit JVM and you will be able to run your code.
If you are going to distribute your application, you will want to build both 32bit and 64bit versions of your DLL. Then use the following technique to have the proper DLL loaded regardless of your customers arch. Append either a 32 or a 64 (MyJniDLL32.dll & MyJniDLL64.dll) to your generated output file.
String archDataModel = System.getProperty("sun.arch.data.model");
System.loadLibrary(libraryName+archDataModel);
Solution 2:
Just to state the obvious: to load a native library built for a 32bit architecture, you have to force the JVM to start in 32bit mode.
java -d32 ...
Possibly you need to install an older JVM for your platform (eg. Oracle's Java 7 on OS X is 64bit only, you need to get Apple's Java 6 from their knowledge base).
Solution 3:
I got that same error message (without the stacktrace) after installing the Java plugin for the Chrome browser.
Re-installing JDK/JRE (this is a development environment) fixed it for me.
Solution 4:
- Download mingw-w64.
- Update your Environment variable PATH.
- Create a C program named test.c which has implementation for your method.
-
Run the following cmd in Command prompt
gcc -Wl,--add-stdcall-alias -I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32" -shared -o test.dll test.c