How do I resolve this UnsatisfiedLinkError? - java

Goodmorning,
Today I started with a POC with SikuliX and Java. I want to try the example in this link. Here a part of the screen is captured and searched.
When I execute this, I receive the error:
[error] RunTimeAPI: loadLib: opencv_java not usable:
java.lang.UnsatisfiedLinkError: no opencv_java in java.library.path: [/usr/java/packages/lib, /usr/lib/x86_64-linux-gnu/jni, /lib/x86_64-linux-gnu, /usr/lib/x86_64-linux-gnu, /usr/lib/jni, /lib, /usr/lib]
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.sikuli.script.FindInput2.<clinit>(FindInput2.java:17)
at org.sikuli.script.Finder.<init>(Finder.java:21)
at org.sikuli.script.Region.doCheckLastSeenAndCreateFinder(Region.java:2936)
at org.sikuli.script.Region.checkLastSeenAndCreateFinder(Region.java:2897)
at org.sikuli.script.Region.doFind(Region.java:2827)
at org.sikuli.script.Region.find(Region.java:2325)
at Apl.sikuliXHighlight(Apl.java:50)
at Apl.main(Apl.java:26)
Caused by: org.sikuli.script.SikuliXception: fatal: problem with native library: opencv_java
at org.sikuli.script.RunTime.terminate(RunTime.java:70)
at org.sikuli.script.RunTime.libsLoad(RunTime.java:792)
at org.sikuli.script.RunTime.loadLibrary(RunTime.java:949)
at org.sikuli.script.Finder2.<clinit>(Finder2.java:35)
... 8 more
[4346 debug] RunTimeAPI: ***** final cleanup at System.exit() *****
I added the library to my POM.XML. But that didn't help.
Did I use the wrong library?
Some additional info:
I am using Intellij on an Ubuntu 18.10 machine.
If I missed something, please let me know. Many thanks in advance.
#Edit:
I had checked out the possible duplicate post. But I am not using OpenCV, but SikuliX. I just need OpenCV as a dependency (as it is being used by SikuliX).
#Edit2:
After more digging and trying to follow the information from the link (duplicate) I found this. Which provides the required info for use on Linux systems.

First check java version.
java -version
After that install opencv
sudo apt install libopencv3.2-java
sudo ln -s /usr/lib/jni/libopencv_java320.so /usr/lib/libopencv_java.so

Related

Configure OpenCV to use in java does not work

Currently I try to use OpenCV in my Java application. In maven I used the newest library
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>4.5.1-2</version>
and I installed OpenCV with
brew install opencv
I also found the installation in
/usr/local/Cellar/opencv/4.5.3/
but when I try to run my java application with
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
i got
Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: no opencv_java453 in java.library.path: [/Users/me/Library/Java/Extensions, /Library/Java/Extensions, /Network/Library/Java/Extensions, /System/Library/Java/Extensions, /usr/lib/java, .]
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2660)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:827)
at java.base/java.lang.System.loadLibrary(System.java:1871)
...
I use IntelliJ and in my run configuration I also added as program argument
-Djava.library.path=/usr/local/Cellar/opencv/4.5.3/lib
but when I read out in this program the java.library.path I got:
properties: /Users/me/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
so I miss the added path...
I also do not found any symbol called opencv_java451 or opencv_java453
can anyone help me? Tanks a lot!
You can find your machine's java.library.path directory.
In my MacBook, it was /Library/Java/Extensions.
Copy the dylib file into it.

Bazel build error "No such file or directory"

I have Ubuntu 16.04. I downloaded and installed bazel according to the official bazel guide and after that I downloaded the first tutorial for building a Java project but it didn't work. I got this exception:
unexpected pipe read status: (error: 2): No such file or directory
Server presumed dead. Now printing '/home/jingw222/.cache/bazel/_bazel_jingw222/ada033fd33c06190d78b77ab4907f1d0/server/jvm.out':
java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.ensureError(J9VMInternals.java:141)
at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:130)
at com.google.devtools.build.lib.skyframe.SkyframeExecutor.skyFunctions(SkyframeExecutor.java:348)
at com.google.devtools.build.lib.skyframe.SkyframeExecutor.init(SkyframeExecutor.java:586)
at com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor.init(SequencedSkyframeExecutor.java:252)
at com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor.create(SequencedSkyframeExecutor.java:211)
at com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor.create(SequencedSkyframeExecutor.java:162)
at com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutorFactory.create(SequencedSkyframeExecutorFactory.java:48)
at com.google.devtools.build.lib.runtime.WorkspaceBuilder.build(WorkspaceBuilder.java:81)
at com.google.devtools.build.lib.runtime.BlazeRuntime.initWorkspace(BlazeRuntime.java:204)
at com.google.devtools.build.lib.runtime.BlazeRuntime.newRuntime(BlazeRuntime.java:1023)
at com.google.devtools.build.lib.runtime.BlazeRuntime.createBlazeRPCServer(BlazeRuntime.java:850)
at com.google.devtools.build.lib.runtime.BlazeRuntime.serverMain(BlazeRuntime.java:789)
at com.google.devtools.build.lib.runtime.BlazeRuntime.main(BlazeRuntime.java:570)
at com.google.devtools.build.lib.bazel.BazelMain.main(BazelMain.java:56)
Caused by: java.lang.ClassCastException: com.ibm.lang.management.UnixExtendedOperatingSystem incompatible with com.sun.management.OperatingSystemMXBean
at com.google.devtools.build.lib.util.ResourceUsage.<clinit>(ResourceUsage.java:45)
... 13 more
What can caouse the problem?
I found this issue, and finally I realized, that I need to download the jdk manually. So I used this command:
sudo apt-get install openjdk-8-jdk
After that I built it again, and it worked well.

OpenJDK 64-Bit Server VM warning: You have loaded library which might have disabled stack guard

can any one help me with this error message .
while try to compile project in eclipse using jNetpcap API
I followed all the steps mentioned on the website below ,how to setup the environment on Debian distribution
http://jnetpcap.com/compile/debian
though I still get the following error message
choosedevice ... OpenJDK 64-Bit Server VM warning: You have loaded
library /usr/lib/libjnetpcap.so.1.3.b0003 which might have
disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c
', or link it with '-z noexecstack'. Exception in thread
"main" java.lang.UnsatisfiedLinkError:
/usr/lib/libjnetpcap.so.1.3.b0003: /usr/lib/libjnetpcap.so.1.3.b0003:
mauvaise classe ELF : ELFCLASS32 (Possible cause: architecture word
width mismatch) at java.lang.ClassLoader$NativeLibrary.load(Native
Method) at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890) at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1880) at
java.lang.Runtime.loadLibrary0(Runtime.java:849) at
java.lang.System.loadLibrary(System.java:1088) at
org.jnetpcap.Pcap.(Unknown Source) at
main.Main_app.choosedevice(Main_app.java:74) at
main.Main_app.main(Main_app.java:273)
By the way I tried to execute " execstac -c " it doesn't work at all
Also I spent days trying to figure out the solution , the only conclusion i come up with so far , is i need to use libjnetpcap.so (64 bit) since i have 64 bit architecture on my Debian .
so is that what i need to do ?
PS : I can't find any ".deb" to install this library for 64 bit.
What does the file /usr/lib/libjnetpcap.so.1.3.b0003 contain?
If the file is a 0-byte-file, there is something really wrong, so try to repair your system by reinstalling that library.
I had the same problem in smartgit, where a library in the local config folder was used, which was somehow corrupted and was a 0 byte file. So deleting the config folder and restarting the app worked for me. This could be a solution here too.

Failed to load sigar-amd64-winnt: java.lang.NullPointerException

I'm new to sigar and native library programming in java, so maybe it is just a simple problem, but I can't find a result on my own.
I'm using eclipse indigo on a win 7 (64bit) OS. I've taken the following steps:
Add sigar.jar an log4l.jar to the jre6/lib, add the sigar-amd64-winnt.dll (also the files for x86) file to ./Program Files/Java/jre6/lib.
Then I only want to create a new sigar() but get the following exception:
Failed to load sigar-amd64-winnt: java.lang.NullPointerException
org.hyperic.sigar.SigarException: Failed to load sigar-amd64-winnt: java.lang.NullPointerException
at org.hyperic.sigar.Sigar.loadLibrary(Sigar.java:170)
at org.hyperic.sigar.Sigar.<clinit>(Sigar.java:100)
at MemExample.<clinit>(MemExample.java:8)
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.hyperic.sigar.Mem.gather(Lorg/hyperic/sigar/Sigar;)V
at org.hyperic.sigar.Mem.gather(Native Method)
at org.hyperic.sigar.Mem.fetch(Mem.java:30)
at org.hyperic.sigar.Sigar.getMem(Sigar.java:304)
at MemExample.getInformationsAboutMemor
I've already tried to manipulate the VM-Arguments (in Run Config -DJava.library.path="path/of/lib"), to set the native library in the java build path to the path of sigar/lib and to set the Systempath in the program on my own with System.setProperty("path", "-"). All of which are unsuccessful until now.
And step by step I yield to despair.
**Edit:**Is it possible that sigar only works with AMD?
Some friend tried the same code with an AMD processor and win 7 (32b) and it works.
I already look for an answer in the hyperic sigar developer forum, but I can't find any useful tips or answers.
Seems that sigar-amd64-winnt.lib is missing: http://communities.vmware.com/message/1947455#1947455

deploy java app on Heroku launch.main error

I want to deploy a java appa on HEROKU. I am new to maven. I made all set up as per in the deploy a sample app to heroku (java+maven+ tomcat7)documentation.
and i made a bulid,It was successfull. But as soon i typed sh /target/bin/weapps i am getting the following error. Can anybody help me to sort out this issue.
Exception in thread "main" java.lang.NoClassDefFoundError: launch/Main
Caused by: java.lang.ClassNotFoundException: launch.Main</br>
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: launch.Main. Program will exit.
regards,
arunbv
I had a similar problem, I (well, almost) solved it this way, just remove:
<packaging>war</packaging>
from pom.xml. I know this is not an ideal solution, but somehow the embedded tomcat plugin doesn't work with war packaging!
I don't have enough points to comment, but what article are you following? Can you link it?
Based on the error, I suspect your Main.java is not in src/main/java/launch. If you follow these instructions, I think you should be able to clear up the error:
http://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat
If that's the article you're following and you're still having trouble, it may ease the problems you're having if you simply clone the sample repo:
git clone git://github.com/heroku/devcenter-embedded-tomcat.git
Since you said you are new to maven, I think the reason of this error is that you simply put your *.java code under the root folder of the project, while you are rather expected to put it under ./src/main/java/
This should work for you. I experienced the same problem and figured this out.
This is probably dead, but in case it helps people of the future.
I was getting up and running with a java app on Heroku, using an Ubuntu machine for development - and got this same Exception in thread "main" java.lang.NoClassDefFoundError.
Double check that you're using the same java compiler version as your java sdk version.
type java -version & javac -version. Make sure they are the same version.
If not, you can fix this by reconfiguring your environment to use the same for both.
Assuming you have downloaded and installed the java version you want to use, type :
`sudo update-alternatives --config java`
You'll get a nice menu with options
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/jdk1.7.0/bin/java 1
Select the version you wish to use. Done.
Now try to build.

Categories