Unsatisfied Linker Error : library file not found - java

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)

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.

Related

Java 3d error when running application from .jar

Hello when i am running my application from Eclipse it runs perfectly but when i export it as a runnable jar, it doesn't run.
When i try running it from cmd it gives me one of 2 errors the first errror is after i just export it with the "copy required libraries into a sub-folder":
Exception in thread "main" java.lang.UnsatisfiedLinkError: no j3dcore-ogl 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 javax.media.j3d.NativePipeline$1.run(NativePipeline.java:189)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.j3d.NativePipeline.loadLibrary(NativePipeline.java:180)
at javax.media.j3d.NativePipeline.loadLibraries(NativePipeline.java:137)
at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:948)
at javax.media.j3d.VirtualUniverse.<clinit>(VirtualUniverse.java:280)
at javax.media.j3d.Canvas3D.<clinit>(Canvas3D.java:3862)
at Main.Game.<init>(Game.java:39)
at Main.Main.main(Main.java:6)
when i change the sub-folder's name from IslandDomination_lib to just lib it gives me another error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/j3d/Canvas3D
at Main.Main.main(Main.java:6)
Caused by: java.lang.ClassNotFoundException: javax.media.j3d.Canvas3D
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
I have tried running it several ways:
1.
java.exe -jar IslandDomination.jar
2.
java.exe -cp "lib/j3dcore.jar;lib/j3dutils.jar;lib/vecmath.jar" -jar IslandDomination.jar
3. using another java program to run it for me:
package main;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException{
ProcessBuilder pb = new ProcessBuilder(System.getProperty("java.home")+"\\bin\\java.exe", "-cp" , "\"lib/j3dcore.jar;lib/j3dutils.jar;lib/vecmath.jar\"" , "-jar" , "IslandDomination.jar");
pb.directory(new File("./"));
Process p = pb.start();
p.waitFor();
}
}
The internal structure of my jar consists of 4 folders:
J3DBool
Main
Maths
META-INF
The folder with the required jars is in the same folder as the main jar
You use a completely obsolete version of Java3D, which is very difficult to bundle in any software as you have to set the Java library path somehow and you have to bundle both the Java libraries and the native libraries. Rather rebuild your project with Java3D 1.6.0 pre 12, it's a lot easier to use as this version relies on JOGL 2 which uses automatic native library loading and everything is packaged as JARs, there is no longer any need of modifying the library path, just take care of the classpath.
Please follow my tutorial, especially the very last section with (a lot) more information.
Finally, the obsolete version that you use isn't guaranteed to work on any recent operating systems. If it works, you'll be lucky; if it doesn't, nobody will fix it.
I think the required library file (jar file) not found in the classpath.
you need to set Library file in your class path.
step to set class path:-
MyComputer->Properties->Advanced system setting->Environment variables
find "classpath" either in user variables area or in system variables if found edit that and put all the jar file link. if not found then create new(click on new) and put all the jar link there and try to run your application
I found out how to fix my problem and it is done by simply putting the needed dll files next to the executable jar file

GLPK java java.lang.UnsatisfiedLinkError: Can't find dependent libraries

The dynamic link library for GLPK for Java could not be loaded.
Consider using
java -Djava.library.path=
The current value of system property java.library.path is:
\\MILP\lib\glpk-4.55\w64
Exception in thread "main" java.lang.UnsatisfiedLinkError:
\\MILP\lib\glpk-4.55\w64\glpk_4_55_java.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.gnu.glpk.GLPKJNI.<clinit>(GLPKJNI.java:24)
at org.gnu.glpk.GLPK.glp_version(GLPK.java:2259)
at TestMain.main(TestMain.java:7)
I have added the correct JAR file
I have given the correct native path for the library
Still the problem persists,
One doubt I have is that the \MILP\lib\glpk-4.55\w64\glpk_4_55_java.dll file is flawed. I checked it using dependencyWalker there it shows some warnings
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Any leads would be appreciated
I also faced same issue. I copied glpk_4_55.dll and glpk_4_55_java.dll to C:\Windows\System32 and Everything works fine for me.
You can add the C:\Program Files\GLPK\glpk-4.55\w64 folder to your PATH environment variable
or
copy the glpk_4_55.dll and glpk_4_55_java.dll to C:\Windows\System32 as suggested by Pradeepb

JNI UnsatisfiedLinkError dependent libraries

I have a JNI dll along with a jar file that I have created on a machine with eclipse.
I am trying to deploy this to another machine and cannot get past the exception
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\CcmAccess\CcmJNIBase.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Meth
at java.lang.ClassLoader.loadLibrary1(Unknown Source)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.sig.ccm.CcmBase.<clinit>(CcmBase.java:8)
at ReadTimeDomain.setupSample(ReadTimeDomain.java:24)
at ReadTimeDomain.main(ReadTimeDomain.java:97)
I have another program that prints out the java.library.path and I have verified the dll that this dll depends on as well as this dll are in the java.library.path.
I have read posts where they should go in the current directory and that doesn't work.
I have read posts where they should go in the jre/bin and that gets the same result.
Any help would be appreciated.
Edit:
If I take everything out of the path and force the classpath to only have the jar file and "." I get the message
Exception in thread "main" java.lang.UnsatisfiedLinkError: no CcmJNIBase in java.library.path
When I add the location of this dll into the path C:\CcmAccess I get the full message:
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\CcmAccess\CcmJNIBase.dll: Can't find dependent libraries
On the machine that this seems to work all I had to do was add the dependent dll to my classpath.
Double check your java.library.path value.
Make sure that you are using an absolute path.
Relative paths will make you think your java.library.path is correct, when actually it is actually incorrect.
If you are adding "." in your java.library.path, then you need to double check the "current working directory" when you execute your code.
If you need to use a relative path in your java.library.path, make sure that the path is relative from the "working directory" when you execute your code.

How to proceed with this exception java.lang.UnsatisfiedLinkError?

this example of code generates an exception :
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-win32-3235 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 org.eclipse.swt.internal.Library.loadLibrary(Library.java:134)
at org.eclipse.swt.internal.win32.OS.<clinit>(OS.java:18)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:125)
at Snippet262.main(Snippet262.java:34)
What does it mean please and how can I resolve it ?
Thank you
You need to add swt-win32-3235.dll to the library_path in your app. By default library_path equals to working dir (".") of your app. Or you may specify path to library_path in vm argument -Djava.library.path=path
So,
1.Check existing swt-win32-3235.dll in your library_path.
2. Check correct definition of library_path property.
This is a runtime exception, that means that the code uses shared library's (using jni probably) which it cannot load.
here you have two options:
the shared library is not installed on you system.
the path to the shared lib is not included in the LD_LIBRARY_PATH (on linux, not sure how it called on windows)
I got the error while running my application. The exception was
java.lang.UnsatisfiedLinkError exception :
SK.gnome.twain.TwainManager.initialize(I[B[BZ)V
I fix it in eclipse as below step, Windows>Preferences>Java>Install JREs>check jre6-32 (check the appropriate versions of jre that you have install in your system).

Eclipse / Java path problems

I'm currently following the third tutorial listed here: here
where I'm trying to compile some matlab code into Java classes. Creating a project in eclipse, and correctly linking the libraries (exactly how its done in the tutorial). Everything actually compiles, but when I run the program I get an Unsatisfied Link error.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: C:\Program Files\MATLAB\R2009b\bin\win32\BuilderJABootstrap.dll
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.<clinit>(MWMCR.java:1571)
at com.demo.DemoMCRFactory.<clinit>(DemoMCRFactory.java:100)
at com.demo.MLTestClass.<init>(MLTestClass.java:62)
at Driver.main(Driver.java:16)
The troubling part is the Can't load library: as the path provided '\win32' is not a legitimate path on my computer as I have a 64 bit machine, so the dll is located at \win64. However, I've triple checked all my Environmental variables and am kind of stuck. Could I be using a 64-bit version of matlab, with a 32-bit library?
Thanks!
ChrisH's solution was it

Categories

Resources