60

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.

15 Answers 15

85

Yes, you'll have to recompile the DLL for 64-bit. Your only other option is to switch to a 32-bit JVM, or otherwise get some 32-bit process to load the DLL on your behalf and communicate with that process somehow.

5
  • How can I switch to a 32 bit JVM? Is that an argument I can pass, or do I need to download and configure something new? Nov 13, 2011 at 17:00
  • 7
    Download and install a 32-bit jvm.
    – bmargulies
    Nov 13, 2011 at 17:42
  • 2
    @Rosarch: Yup, a 64-bit machine can run 32-bit executables. That will be the easiest way to get a 32-bit DLL to work. Nov 14, 2011 at 1:34
  • 2
    "Yes, you'll have to recompile the DLL for 64-bit." How?
    – John Perry
    Jan 7, 2022 at 22:32
  • @JohnPerry you need to be the author of the DLL or have access to the DLL's codebase. Usually, you will use either CMake or Visual Studio to compile into a dynamically linked library. Sep 23, 2022 at 2:59
5

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.

1
  • 3
    Hi can you elaborate on how you got your app to point to 32-bit JRE? Is that something you did in your IDE or programmatically? Aug 9, 2017 at 16:11
2

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.

1
  • I asked multiple questions. Which are you answering "yes" to? ha. Nov 13, 2011 at 18:40
1

Had same issue in win64bit and JVM 64bit

Was solved by uploading dll to system32

1
  • 2
    that's not possible, the location of the file doesn't change anything
    – FiruzzZ
    Mar 12, 2019 at 23:44
1

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

1
  • 2
    Maybe you mea to "use a jvm that is found under Program Files (x86), to ensure it's a 32 bit version" ?? Feb 16, 2016 at 8:23
1

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 );
1

Go to

Project properties >> Run >> VM options

and put this address:

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

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

0

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
0

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).

0

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

0

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.

0

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.

0

no build for Win64 necessary.

Download 64x version on https://tomcat.apache.org/download-native.cgi

from one of the mirrors i.e.

https://mirror.checkdomain.de/apache/tomcat/tomcat-connectors/native/1.2.28/binaries/tomcat-native-1.2.28-openssl-1.1.1k-win32-bin.zip

from zip use:

bin\x64\tcnative-1.dll

0

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.6.0_45;..

Not the answer you're looking for? Browse other questions tagged or ask your own question.