简体   繁体   中英

How to fix java.lang.UnsatisfiedLinkError-Problem with 64-bit / 32-bit Systems?

I hava a 64-bit System and want want to run a Java-Application that needs to load a 32-bit dll-file. I want to load the libary using System.load() . When using a 64-bit Java-8-JRE the following error occurs:

java.lang.UnsatisfiedLinkError: C:\[...]\test.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform. 

When running the application on a 32-bit Java-6-JRE it sais

java.lang.UnsatisfiedLinkError: C:\[...]\test.dll: Can't find dependent libraries

I tried to use a 64-bit version of Java. Because the dll is a 32-bit dll I tried to run the application on a 64-bit-version. But then another error occures.

I also tried to use System.loadLibrary() instead. But the errors seem to be similar.

Java-8-64-bit:

java.lang.UnsatisfiedLinkError: C:\Windows\System32\test.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform

--> Because of this error I can be sure java is able to find this file in general.

Java-6-32-bit:

java.lang.UnsatisfiedLinkError: no test in java.library.path

--> Because of the error shown before the file have to be there.

My code of the application is very short:

Using System.load() :

public static void main(String[] args) {
    System.load("C:\\[...]\\test.dll");
}

Using System.loadLibary() :

public static void main(String[] args) {
    System.loadLibrary("test");
}

The file has all necessary permissions.

The typical error that the file is not in the PATH can be excluded because running a 64-bit-JVM the file can be found but can not be read because it needs a 32-bit JVM.

Has anybody any ideas? Thanks!

The solution is very simple...

Regarding the thread https://stackoverflow.com/a/12307577/11011623 the System32-folder, where my file and my dependencies have been, just allows 64-bit-binaries to be in it. So the 32-bit-dll was not found. When using System.load() and the dll at another path the system was not able to locate the necessary dependencies in the dll because the path where the dll is, is not part of the path...

Solution was to move all necessary files from System32 to Windows folder or to add a custom folder with all dlls and its dependencies to the PATH. Thanks for all comments that helped solving this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM