[java] Can't load IA 32-bit .dll on a AMD 64-bit platform

I am trying to use SVMLight from Java, using the JNI wrapper on this page:

  static {
    System.loadLibrary("lib/JNI_SVM-light-6.01/lib/svmlight");
  }

I get the following error:

... lib\JNI_SVM-light-6.01\lib\svmlight.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform

Can I solve this by recompiling the .dll for 64 bit? How would I go about doing this? Is there some other workaround I can use? SVMLight makes the C source code available.

This question is related to java windows dll java-native-interface

The answer is


My windows laptop has both the clients 32 & 64 bit I started facing all of sudden then I reordered the path variable like below

Before:

C:\app\oracle64\product\12.1.0\client_1\bin;
C:\app\oracle32\product\12.1.0\client_1\bin;

After:

C:\app\oracle32\product\12.1.0\client_1\bin;
C:\app\oracle64\product\12.1.0\client_1\bin;

started working... Hope this helps everyone.


Be sure you are setting PATH to Program Files (x86) not Program Files. That solved my problem.


I had an issue related to this and was reading

"Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\opencv\build\java\x86\opencv_java2413.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform "

and it took me an entire night to figure out.

I solved my problem by copying the dll in C:\opencv\build\java\x64 to my system32 folder. I hope this will be of help to someone.


Don't worry about you should just change .dll from x64 to x86, in the native library.

for example:- you might have selected this (C:\opencv\build\java\x64).

instead you select this for native library(C:\opencv\build\java\x86).


I had the same issue with a Java application using tibco dll originally intended to run on Win XP. To get it to work on Windows 7, I made the application point to 32-bit JRE. Waiting to see if there is another solution.


Just go to install download jdk_x86 and it install in Program Files (x86) and set the jre path in your project. Thats it.


Short answer to first question: yes.

Longer answer: maybe; it depends on whether the build process for SVMLight behaves itself on 64-bit windows.

Final note: that call to System.loadLibrary is silly. Either call System.load with a full pathname or let it search java.library.path.


Here is an answer for those who compile from the command line/Command Prompt. It doesn't require changing your Path environment variable; it simply lets you use the 32-bit JVM for the program with the 32-bit DLL.

For the compilation, it shouldn't matter which javac gets used - 32-bit or 64-bit.

>javac MyProgramWith32BitNativeLib.java

For the actual execution of the program, it is important to specify the path to the 32-bit version of java.exe

I'll post a code example for Windows, since that seems to be the OS used by the OP.

Windows

Most likely, the code will be something like:

>"C:\Program Files (x86)\Java\jre#.#.#_###\bin\java.exe" MyProgramWith32BitNativeLib 

The difference will be in the numbers after jre. To find which numbers you should use, enter:

>dir "C:\Program Files (x86)\Java\"

On my machine, the process is as follows

C:\Users\me\MyProject>dir "C:\Program Files (x86)\Java"
 Volume in drive C is Windows
 Volume Serial Number is 0000-9999

 Directory of C:\Program Files (x86)\Java

11/03/2016  09:07 PM    <DIR>          .
11/03/2016  09:07 PM    <DIR>          ..
11/03/2016  09:07 PM    <DIR>          jre1.8.0_111
               0 File(s)              0 bytes
               3 Dir(s)  107,641,901,056 bytes free

C:\Users\me\MyProject>

So I know that my numbers are 1.8.0_111, and my command is

C:\Users\me\MyProject>"C:\Program Files (x86)\Java\jre1.8.0_111\bin\java.exe" MyProgramWith32BitNativeLib

Got this from - http://blog.cedarsoft.com/2010/11/setting-java-library-path-programmatically/

If set the java.library.path, need to have the following lines in order to work.

Field fieldSysPath;
fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" );
fieldSysPath.setAccessible( true );
fieldSysPath.set( null, null );

Had same issue in win64bit and JVM 64bit

Was solved by uploading dll to system32


Go to

Project properties >> Run >> VM options

and put this address:

-Djava.library.path="C:\opencv\build\java\x64"

I had a problem when run red5(tomcat) on Windows x64 that previous worked under Windows x32, got next error:

 INFO pool-15-thread-1 com.home.launcher.CommandLauncher - Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\....\lib\Data Samolet.dll: Can't find dependent libraries
INFO pool-15-thread-1 com.home.launcher.CommandLauncher - at java.lang.ClassLoader$NativeLibrary.load(Native Method)

Problem solved when I installed Java x32 version and set next

"Environment variables"

"User variables for Home"

JAVA_HOME => C:\Program Files (x86)\Java\jdk.1.6.0_45

"System variables"

Path[at the beginning] => C:\Program Files\Java\jdk.1.8.0_60;..


For your Native library location, use X64 over X86. At least this fixed problem I had.


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to windows

"Permission Denied" trying to run Python on Windows 10 A fatal error occurred while creating a TLS client credential. The internal error state is 10013 How to install OpenJDK 11 on Windows? I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."? git clone: Authentication failed for <URL> How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" XCOPY: Overwrite all without prompt in BATCH Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory how to open Jupyter notebook in chrome on windows Tensorflow import error: No module named 'tensorflow'

Examples related to dll

The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing while starting Apache server on my computer PHP 7: Missing VCRUNTIME140.dll How to fix PHP Warning: PHP Startup: Unable to load dynamic library 'ext\\php_curl.dll'? WampServer: php-win.exe The program can't start because MSVCR110.dll is missing msvcr110.dll is missing from computer error while installing PHP installing JDK8 on Windows XP - advapi32.dll error The program can’t start because MSVCR71.dll is missing from your computer. Try reinstalling the program to fix this program ImportError: DLL load failed: %1 is not a valid Win32 application. But the DLL's are there Loading DLLs at runtime in C# Missing `server' JVM (Java\jre7\bin\server\jvm.dll.)

Examples related to java-native-interface

A JNI error has occurred, please check your installation and try again in Eclipse x86 Windows 8.1 JNI and Gradle in Android Studio how to make jni.h be found? Eclipse reported "Failed to load JNI shared library" Can't load IA 32-bit .dll on a AMD 64-bit platform Failed to load the JNI shared Library (JDK) What is the native keyword in Java for? How to fix an UnsatisfiedLinkError (Can't find dependent libraries) in a JNI project Calling a java method from c++ in Android Converting from signed char to unsigned char and back again?