Reputation: 457
I am writing test cases for a class that calls the constructor of another class that has a static block that loads a c++ library,
static
{
System.loadLibrary("PixelProxy_jni");
}
I have specified the library path as,
-Djava.libarary.path=C:\Users\Desktop\libPixelProxy_jni.so
in the vm arguments in eclipse, but still it doesn't work.
Please help me find a solution for this
stack trace
java.lang.UnsatisfiedLinkError: no PixelProxy_jni in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.XrayPixelProxyInputStream.<clinit>(XrayPixelProxyInputStream.java:36)
at com.RadImageReader.readImage(RadImageReader.java:57)
at servicedisplay.ServiceImageDisplayer.showImage(ServiceImageDisplayer.java:124)
at servicedisplay.test1.ServiceImageDisplayerTest.testShowImageStringIntIntIntIntIntInt(ServiceImageDisplayerTest.java:95)
Upvotes: 1
Views: 961
Reputation: 33895
From that file path, it looks like you're on windows, which means that loadLibrary
will not look for a file named libPixelProxy_jni.so
, it will look for a file named PixelProxy_jni.dll
. (You can find out exactly what it will look for by using System.mapLibraryName
.)
You can either find a .dll
of the library, compile one yourself, or try System.load
, which allows you to load a native library from an absolute path:
System.load("C:\Users\Desktop\libPixelProxy_jni.so");
But that will only work if the library was actually compiled for windows.
Upvotes: 1