Java, Eclipse keep getting java.lang.UnsatisfiedLinkError openDMX - java

I tried downloading the open DMX java wrapped form here. I'm using Eclipse as IDE. When I run the example I got the java.lang.UnsatisfiedLinkError openDMX.
So I googled the hell out of it and I found out that I had to define the build path of the dll file (from what I found this had to do with the driver for the usb device?)
I tried the following:
Definde the path in run configurations->vm arguments and then -Djava.library.path=dll
as was included in the readme. This gave the same exception
Then I found that I could define the build path. Right clicked the main folder in the file browser in eclipse.
Then properties->libraries->JRE system libraries->native library location
I browsed in the workspace for de dll folder and set the opendmx_example/dll as the native library location
Stil: Exception in thread "main" java.lang.UnsatisfiedLinkError: no opendmx in java.library.path
Does somebody experience the same trouble or is it something that I'm doing wrong
Any help is much appreciated!

Related

OpenCV 4.3.0 java.lang.UnsatisfiedLinkError in Eclipse

I'm trying to do some template matching with the Java binding of OpenCV 4.3.0 in Eclipse, but attempting to load the template image always results in this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.imgcodecs.Imgcodecs.imread_0(Ljava/lang/String;I)J
The line of code where this exception is thrown is this:
flowerTemplate = Imgcodecs.imread("/templates/flowerpot_white.png", Imgcodecs.IMREAD_COLOR);
I have tried a number of solutions suggested on similar questions on StackOverflow and elsewhere on the internet, including:
Pointing at the native library folder with the "Native library location" variable in the user library definition in Eclipse.
Adding the native library folder location to my PATH variable.
Adding the native library .dll location to my PATH variable.
Setting up the Eclipse run configuration to add the native library folder & .dll locations to the PATH and CLASSPATH variables.
Loading the library with the appropriate Java code, in each of the three ways I saw it suggested, in three different places which all run before the code that throws the exception.
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
System.load(<path_to_the_dll>);
File opencvLibrary = new File(System.mapLibraryName(Core.NATIVE_LIBRARY_NAME));
System.load(opencvLibrary.getAbsolutePath());
Placing the .dll in question into my source folder and every subfolder. I am running it from within Eclipse, so this is also the program's working directory.
UnsatisfiedLinkError is a runtime exception that happens when running your Java program. So placing your file in the source folder will not work.
You need it to be available in a place that your program can find it.
See this article for example:
https://www.javaworld.com/article/2077520/java-tip-23--write-native-methods.html
In it they place the library in Linux's library path. In windows you'd similarly place it in the current directory (where you're running from) or in some shared location.
This article explains Window's dll search order: https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order
You shouldn't need to explicitly call System.loadLibrary() yourself. That's the library's responsibility.
Your problem is that OpenCV is improperly installed on your machine or inaccessible from Eclipse.
For instructions on how to make in work in Eclipse see:
Add .dll to java.library.path in Eclipse/PyDev Jython project
After removing every load method and then adding them back one-by-one, I determined that the issue was most likely caused by Eclipse loading the native library folder twice.

UnsatisfiedLinkError loading OpenCV (Linux)

I need to create a runnable jar in Windows with Eclipse and start it with Linux
I'm getting an unsatisfiedLinkError while loading OpenCv. I have edited the correct library path for a Linux computer in Eclipse and finally created a runnable jar. When I start the *.jar file in linux and get the following error.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no
opencv_java2411 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1889)
at java.lang.Runtime.loadLibrary0(Runtime.java:900)
at java.lang.System.loadLibrary(System.java:1087)
Basically i have two question.
1. How can i get the loaded library path at runtime?
2. Is it possible that the chosen way is not the right way to handle the problem?
Thanks
One important this to keep in mind for loading linux libraries with System.loadLibrary, omit the lib prefix in the library name, for instance, if the library name is libxyz.so, your call would be:
System.loadLibrary("xyz");
Set the path of OpenCV in the variable LD_LIBRARY_PATH. You can do it in the shell where you run the "jar". Use export command.

Java exception: java.lang.UnsatisfiedLinkError: gnu.io.RXTXCommDriver.nativeGetVersion()Ljava/lang/String;

I am a java programmer in Korea(South).
I have searched many google articles about these errors.
java.lang.UnsatisfiedLinkError:
gnu.io.RXTXCommDriver.nativeGetVersion()Ljava/lang/String; thrown while loading gnu.io.RXTXCommDriver
java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver thrown while loading gnu.io.RXTXCommDriver
but I haven't solved it yet.
My eclipse build path setting is like this.
I added external jars from
C:\dev\java\jdk_6\jre\lib\ext\RXTXcomm.jar
and Native library location for RXTXcomm.jar is
C:\dev\java\jdk_6\jre\bin\rxtxSerial.dll
and I`m using springframework
build has no error.
and Tomcat v6.0 start has no error.
But when I try to use the component from jar, file error pops-up.
If anyone have a solution please give me a tip.
First I checked lib and bin directories of jdk and jre.
There was many RXTXcomm.jar and rtxtSerial.dll in many directories.
So I erased all of RTXTcomm.jar and rtxtSerial.dll.
Then I re-downloaded RTXTcomm.jar and rtxtSerial.dll from
http://fizzed.com/oss/rxtx-for-java
and put then in
C:\dev\java\jdk_6\jre\lib\ext\RXTXcomm.jar
C:\dev\java\jdk_6\jre\bin\rxtxSerial.dll
and..
C:\dev\RXTXcomm.jar
C:\dev\rxtxSerial.dll
after that
I added java build path in my eclipse.
Project > Properties > Java build path > library tab > add external jar
select "C:\dev\RXTXcomm.jar" > Native library location > edit
select "C:\dev\rxtxSerial.dll"
Finally,
It worked very well.
I think the problem was jar file. I think it was corrupted.
(Sorry My English is not good. I hope you understand what I wrote.)

Indri library java.lang.UnsatisfiedLinkError..change to java.lang.NoClassDefFoundError only on the server

I have this web application where I use the indri.jar in it. I am using eclipse.
I have put it in the lib folder and did "add to build path" option.
Also in "Build Path -> Configure -> Order and Export", everything is checked.
Also in "Properties -> Deployment assembly", all the jar files are added. Then I export the project to .war and put it on the server.
I checked the lib folder of the deployed project and the jar file is there.
Also my machine and server are both 64 bit, since for this library there are two versions for 32 and 64 bit, and it wont work if you use them instead of each other.
It is also important to say that we are a team working on this project using git repository, and when the other side pull the code all the libraries and everything is attached and they have no problem running the code. (They have installed indri, and I did install it on the server)
Still when I open the page in the browser it gives me "error in ajax call" and when I trace the error it gives me:
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.UnsatisfiedLinkError: no indri_jni in java.library.pathorg.etc.
root cause
org.glassfish.jersey.server.ContainerException: java.lang.UnsatisfiedLinkError: no indri_jni in java.library.pathorg.glassfish.etc
root cause
java.lang.UnsatisfiedLinkError: no indri_jni in java.library.pathjava.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)java.lang.Runtime.loadLibrary0.etc.
I searched a lot and then I ran this line on the server:
java -Djava.library.path=/path/to/jnilib/directory MainClass
Then the error changed to this:
exception
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: Could not initialize class lemurproject.indri.indriJNIorg.glassfish
root cause
org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: Could not initialize class lemurproject.indri.indriJNIorg.glassfish.jersey.servlet
java.lang.NoClassDefFoundError: Could not initialize class lemurproject.indri.indriJNIlemurproject.indri.QueryEnvironment.<init>(QueryEnvironment.java:39)LogicLayer.IndriIndex.processQuery(I...
Note:
Indri is working on command line on the server, so the problem is not with indri but is with deploying.
When I deploy the code by commenting the lines related to Indri, it works, that shows I am exporting to .war correctly.
There is an important file in indri installation which is libinrdi_jni.so, which has the role of linking java to c language which is the language the library has been written to. It is located in the indri installation foler: ./install/lib/libindri_jni.so.
My code couldn't find this file. So I had to put it somewhere in the server that it will definitely look into and then it did find it and everything worked.
To make sure that you will have this file you need to install indri in this way:
./configure --enable-java --with-javahome=address/to//jdk1.7.0 --prefix=/address/to/indri-5.7/install
make all install
make sure to download the jdk1.7 and extract it yourself instead of using any install package. This way the libindri_jni.so will be installed.
Then to make sure that your java program will work, you need to run IndexUI.jar, and RetUI.jar, provided in the indri folder. If it works, then your program will work too, but if it is not working, then try running this command:
export LD_LIBRARY_PATH=/address/to/indri-5.7/install/lib
then run the jar file again, if the problem has been resolved, the libindri_jni.so file is the problem and you can solve it by locate it in a place that program can definitely find it.

java.lang.UnsatisfiedLinkError

I am trying to use an applet I downloaded. I get the following error when using it
Can't load library 'friend'.
java.lang.UnsatisfiedLinkError:no friend in java.library.path
No resource '/libfriend.so' found.
Please help. Thank you.
the application is looking for a native library called libfriend.so in your path. I'm assuming you're on linux, if so and you have the .so file you can add it to your path, if you are on windows you are out of luck.

Categories