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.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699

15 Answers15

83

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.

Daniel Pryden
  • 59,486
  • 16
  • 97
  • 135
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.

aditya
  • 112
  • 1
  • 10
  • 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? – Janac Meena Aug 09 '17 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.

bmargulies
  • 97,814
  • 39
  • 186
  • 310
1

Had same issue in win64bit and JVM 64bit

Was solved by uploading dll to system32

Yaro
  • 614
  • 6
  • 13
1

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

Wojciechu
  • 3,314
  • 2
  • 14
  • 10
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"
Laurel
  • 5,965
  • 14
  • 31
  • 57
eng_hish
  • 7
  • 2
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.

Ramapati Maurya
  • 654
  • 9
  • 11
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.8.0_60;..

Denys Zotov
  • 11
  • 1
  • 3
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.

Jee Mok
  • 6,157
  • 8
  • 47
  • 80
Oti
  • 1
  • 1
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
bballdave025
  • 1,347
  • 1
  • 15
  • 28
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).

Akash
  • 11
  • 1
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.

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
0

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

이재찬
  • 56
  • 7
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

Jundl
  • 3,084
  • 3
  • 15
  • 16