I'm making a program use JNI to call some native directives. My code is:System.loadLibrary("poc_NativeShellExecutor");
When I run the code, I got the 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 the java.library.path
and I'm sure I do put the poc_NativeShellExecutor.dll in C:\Windows\System32.
Here is some info of 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 u please give me some help?
This is not the solution, but additional data, that I hope can help to find one.
I have the same issue as the OP.
My system is Windows7 Ultimate x64 SP1
.
I run my 32-bit test_x86.dll
using the 32-bit jvm 1.6.0_29.
I've tried to place test_x86.dll
in the following folders:
C:\
C:\Windows
C:\Program Files (x86)
and it works: my test_x86.dll
is successfully loaded.
But if I place my dll into
C:\Windows\System32
I get the exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no test_x86 in java.library.path
I change my java.library.path
each time before trying to load the dll, so it always starts with the corresponding 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 also tried to use the default java.library.path
(that contains C:\Windows\System32
by default) with test_x86.dll
in C:\Windows\System32
. No luck: it also leads to the exception above.
I always have the single copy of test_x86.dll
in folders that are in the java.library.path
, i.e. only one of the folders contain that file at a time.
It seems that in Windows 7 x64 the C:/Windows/System32
have some tricky restrictions.
Earlier on my Windows XP 32-bit machine, I never warried about C:\Windows\System32
folder and java.library.path
changes. I've simply used the System.loadLibrary("test_x86");
call with test_x86.dll
in that folder, and it always worked.