Load dll when using System.loadLibrary ()

I am using JNI to use some of the native directives. My code:System.loadLibrary("poc_NativeShellExecutor");

When I run the code, I got an exception:

Caused by: java.lang.UnsatisfiedLinkError: no poc_NativeShellExecutor in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860) at java.lang.Runtime.loadLibrary0(Runtime.java:845) at java.lang.System.loadLibrary(System.java:1084)

I check java.library.path

and I am sure that I have put poc_NativeShellExecutor.dll in C: \ Windows \ System32. Here's some information about my system:

Java version: 1.7.0_03, vendor: Oracle Corporation
Java home: E:\Program Files (x86)\Java\jdk1.7.0_03\jre
Default locale: en_US, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

      

Could you help me?

+3


source to share


2 answers


This is not a solution, but additional data that I hope will help find them.

I have the same problem as OP.

My system Windows7 Ultimate x64 SP1

.
I am running my 32 bit test_x86.dll

using jvm 1.6.0_29 32 bit.

I tried to place test_x86.dll

in the following folders:

C:\
C:\Windows
C:\Program Files (x86)

      

and it works: mine test_x86.dll

loaded successfully.

But if I put my dll in

C:\Windows\System32

      

I am getting an exception:



Exception in thread "main" java.lang.UnsatisfiedLinkError: no test_x86 in java.library.path

      

I change mine java.library.path

every time before I try to load the DLL, so it always starts at the appropriate directory:

java.library.path = C:/;C:\Program Files (x86)\Java\jre6\bin; ...
java.library.path = C:/Windows;C:\Program Files (x86)\Java\jre6\bin; ...
java.library.path = C:/Program Files (x86);C:\Program Files (x86)\Java\jre6\bin; ...
java.library.path = C:/Windows/System32;C:\Program Files (x86)\Java\jre6\bin; ...

      

I have also tried using the default java.library.path

(which contains C:\Windows\System32

the default) from test_x86.dll

in C:\Windows\System32

. No luck: this also throws the above exception.

I always have a single copy test_x86.dll

in the folders located in java.library.path

i.e. only one of the folders contains this file at a time.

Output:

It seems like Windows 7 x64 C:/Windows/System32

has some tricky limitations.

Previously on my Windows XP 32-bit machine, I never looked for changes in the C:\Windows\System32

and folder java.library.path

. I just used a call System.loadLibrary("test_x86");

with test_x86.dll

in this folder and it always worked.

+3


source


If you refer to C: \ Windows \ System32 on 64-bit Windows from a 32-bit application, Windows actually looks in C: \ Windows \ SysWOW64. You will need to host the DLL for 32 bit applications.



+1


source







All Articles