UnsatisfiedLinkError when trying to load dll in my eclipse project - java

I have 'xxx.dll' file along with a couple of other dlls at the location -
'C:\Program Files (x86)\abc\xyz\Librerias'
trying to load this dll file in my project using
System.loadLibrary("xxx");
added this path to 'Native library location' in JRE System Library in Configure Build Path but still the line trying to load this dll is throwing 'UnsatisfiedLinkError'.
I even tried but still same error remains.
System.load("C:/Program Files (x86)/abc/xyz/Librerias/xxx.dll");
I do have latest version of 32-bit JRE and JDK added in my system path and I am using a 64-bit machine.

The system was not able to navigate to that directory because of those non-existent paths. In order to solve that I just did opposite, added location of native library in front of PATH and it worked like a charm.
this helped.

Related

How do I add a shared library file to the java.library.path in Eclipse?

I'm running Ubuntu 20.04 with Eclipse version 2019-12 and OpenJDK 8 (as my current project requires version 8). The Java project can be successfully executed using this script:
Working in Eclipse, I want to add an external JAR file to the project, but I keep getting following exception:
I've tried the following:
1. Adding the native library location containing all the shared libraries
The depicted location contains the file "libz3java.so". Adding the same native library location to other JARs did not change the result.
2. Setting the java.library.path via VM arguments
3. Adding an environment variable
4. Adding the prefix "lib" to the shared library filename
This is the only way I was able to get another exception. I renamed "libz3java.so" to "liblibz3java.so" getting following exception:
"libz3.so" is another shared library found in the same directory. Adding the prefix "lib" to that library name doesn't change the exception.
How do I tell Eclipse where to find and read the missing shared library?
When adding an environment variable, you have to explicitly use "/home/user/" instead of "~". However, I still don't understand why adding a native library or doing it via VM arguments doesn't work. I recall successfully linking the library as shown in my first attempt with the native library in newer versions (>4.8.6) of Z3 on Ubuntu 16.04.

Fails to run a Jar file on macOS using Zulu JRE (8.271)

java -jar jarfile works perfectly on Windows/Ubuntu, yet on macOS, I keep getting "Could not find or load main class."
Not only that, when I run the jar using Oracle's JRE - it works (the oracle's JRE isn't part of the path, so I write the absolute path in order to verify the right version I'm running).
So using absolute paths to the jre\bin\java files, once to the Oracle's JRE (works), once to the Zulu's Mac version JRE and I get "Could not find or load main class."
Any idea?
I used a simple java -jar jarfile command.
The Manifest file in the Jar does include a Main file reference (an obfuscated Main file) yet has no reference to a classpath (we wrap everything inside one JAR so we don't have any external jar dependency).

java.lang.UnsatisfiedLinkError: no jzmq in java.library.path

I have a java application using an external dll (zmq). When I run it in debug mode in Eclipse it's all fine. However, when I export the application as Runnable JAR file then trying to run it, I'm getting that error referencing the dll.
Following my research on this site I configured the build path for JRE System Library, added that path of the folder containing the dll to Native library location, but I'm still getting that error.
Is there anything I need to do further? Or different?
Thanks.
JZMQ needs two things to run: zmq.dll (the native ZMQ library) and jzmq.dll (the "bridge" library between Java and ZMQ). The particular error you are getting means your compile environment can't locate jzmq.dll; you just need to specify the path where it can find jzmq.dll. Note that, as far as I'm aware, there is no way for jzmq.dll to be in a JAR file so you can just include it in your classpath.
Unfortunately, I can't tell you exactly how to do it in Windows. I come from Linux, where DLLs are SO files. There it would be a simple export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/jzmq.

Unable to load library 'libtesseract302' in Play project

I'm trying to use tess4j in a play project. I have put tess4j.jar, libtesseract302.dll and liblept168.dll in play project lib folder and setting java.library.path and jna.library.path when starting play server like this:
play -Djava.library.path=lib -Djna.library.path=lib start
Note that i have used 64-bit dlls which have been released here: https://github.com/charlesw/tesseract/tree/master/src/lib/TesseractOcr/x64. This link has been stated in Tess4j official website as well.
But still, i'm getting " Unable to load library 'libtesseract302'" exception. I tried to set the absolute path of lib folder too, nothing works.
Any help would be much appreciated.
Thanks.
For using Tess4j try putting the libtesseract302.dll in the Project Folder and not in the lib Folder.
That is how it worked in my project.
But The error can be a result from various situations other than the location of .dll file
This problem may arise when -
You are trying run Tess4j on a 64 bit JVM instead of 32 bit, it gives the same error inspite of placing the .dll files into the perfect location
You do not have Microsoft Visual C++ 2008 redistributable installed (Specifically 2008)
http://www.microsoft.com/en-in/download/details.aspx?id=29
After fixing all these it should work
Put the JAR in the classpath. java.library.path is for the native libraries (.dll, .so, .dylib).

JNA Win7 The specified module could not be found

I have been using JNA to load a native dll and could successfully develop the application on XP.
When I try to run the same on a Win7 machine, I get the error, The specified module could not be found.I am unable to load the DLL.
Using dependency walker I looked at the DLL dependencies and all other necessary DLLs are present under C:\Windows\system32 which is already added in the PATH environment variable.
Am I missing something. Please suggestions.
Thanks !

Categories