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.
Related
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
I have been trying to install Java3D 1.5.2 on my Mac (OS 10.10). First I tried using the installer referenced in this answer by whiskeyspider. It installed the files, but I got an error when I tried to run a program. So I cleared out /Library/Java/Extensions and tried to install manually in ~/.local/lib, a directory I created previously, and just include the jars in my project's build path (Eclipse). Despite including the jars and native library locations (for the JOGL jars) I get the following error when I try to run the program:
Exception in thread "J3D-Renderer-1" java.lang.UnsatisfiedLinkError: /Users/brianmc7/.local/lib/jogl/lib/libjogl_awt.jnilib: dlopen(/Users/brianmc7/.local/lib/jogl/lib/libjogl_awt.jnilib, 1): Library not loaded: /System/Library/Frameworks/JavaVM.framework/Libraries/libjawt.dylib
Referenced from: /Users/brianmc7/.local/lib/jogl/lib/libjogl_awt.jnilib
Reason: image not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1851)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at com.sun.opengl.impl.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:189)
at com.sun.opengl.impl.NativeLibLoader.access$000(NativeLibLoader.java:49)
at com.sun.opengl.impl.NativeLibLoader$DefaultAction.loadLibrary(NativeLibLoader.java:80)
at com.sun.opengl.impl.NativeLibLoader.loadLibrary(NativeLibLoader.java:103)
at com.sun.opengl.impl.NativeLibLoader.access$200(NativeLibLoader.java:49)
at com.sun.opengl.impl.NativeLibLoader$2.run(NativeLibLoader.java:132)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.opengl.impl.NativeLibLoader.loadAWTImpl(NativeLibLoader.java:118)
at com.sun.opengl.impl.JAWT.getJAWT(JAWT.java:91)
at com.sun.opengl.impl.macosx.MacOSXOnscreenGLDrawable.lockSurface(MacOSXOnscreenGLDrawable.java:144)
at com.sun.opengl.impl.macosx.MacOSXOnscreenGLContext.makeCurrentImpl(MacOSXOnscreenGLContext.java:57)
at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:134)
at javax.media.j3d.JoglPipeline$QueryCanvas.doQuery(JoglPipeline.java:9049)
at javax.media.j3d.JoglPipeline.getBestConfiguration(JoglPipeline.java:8797)
at javax.media.j3d.Renderer.doWork(Renderer.java:514)
at javax.media.j3d.J3dThread.run(J3dThread.java:275)
It turns out that the directory /System/Library/Frameworks/JavaVM.framework/Libraries/ doesn't exist. How can I fix this problem?
EDIT: I should probably also mention that I am using JDK 1.8.0_40 early access.
Java3D was abandoned by Sun Microsystems / Oracle in 2008. Java3D has been maintained by the JogAmp community since 2012. Yes, Java3D 1.6 is composed of several pre-releases but they work much better than Java3D 1.5.
My own tutorial explains in details how to install the very latest version of Java3D.
I got a .jar file from a code that works on Windows, and I'm trying to run it on Linux, but I keep getting this message, and don't know what to do.
Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: no usbJava in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1856)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at ch.ntb.usb.LibusbJava.<clinit>(LibusbJava.java:366)
at ch.ntb.usb.USB.init(USB.java:315)
at ch.ntb.usb.USB.getBus(USB.java:296)
at ch.ntb.usb.Device.initDevice(Device.java:102)
at ch.ntb.usb.Device.open(Device.java:222)
at TransmitterModuleHIDInterface.run(TransmitterModuleHIDInterface.java:28)
at java.lang.Thread.run(Thread.java:722)
I'm using the Java wrapper for the libusb-0.1 (I followed the installation instructions here).
Any help would be really appreciated!
You need to create a link to the shared library, as per the Linux installation instructions:
http://libusbjava.sourceforge.net/wp/?page_id=8
If you're having trouble building the shared library this might be of some help:
http://me.opengroove.org/2010/01/libusbjavaso.html
The sources for the library itself is under /libusbjava/trunk/LibusbJava/ in the SVN source tree.
I'm trying to run an internal web browser using JWebBrowser. When I run the application in Netbeans environment it works perfectly. However, when I build the project and run the jar file I'm getting the following error:
NativeSwing[1]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Could
not load SWT library. Reasons:
NativeSwing[1]: no swt-gtk-3721 in java.library.path
NativeSwing[1]: no swt-gtk in java.library.path
NativeSwing[1]: Can't load library: C:\Users\CCS.swt\lib\win32\amd64\swt-gtk-3721.dll
NativeSwing[1]: Can't load library: C:\Users\CCS.swt\lib\win32\amd64\swt-gtk.dll
I'm including the following libraries to the project:
DJNativeSwing.jar
DJNativeSwing-SWT.jar
DJNativeSwing-SWTAPI.jar
DJNativeSwing-SWTCore.jar
MozillaInterfaces-1.8.1.3.jar
swt.jar (version 3.7M5 for 64 bits.)
jna_WindowUtils.jar
jna-3.2.4.jar
and they're referenced by Manifest.MF by this way
Class-Path: lib/DJNativeSwing-SWT.jar lib/DJNativeSwing-SWTAPI.jar lib
/DJNativeSwing-SWTCore.jar lib/MozillaInterfaces-1.8.1.3.jar lib/DJNa
tiveSwing.jar lib/swt.jar lib/jna-3.2.4.jar lib/jna_WindowUtils.jar
What am I doing wrong?
Thank you.
You need to specify the java.library.path in the java command and aim it at the path to your .dll files. For example,
java -Djava.library.path=lib -cp ...
Ok, I found the solution. The problem was about the dll generation. I was using 3.7m5 version, I downloaded a previous version (3.7) and the application ran properly.
Thank you for your help.
Regards.
I am trying to get J3D to work in Eclipse and have read forum after forum but can't seem to fix my problem. I am using ubuntu 11.10
I have done this:
0) unzipped j3d-1_5_2-linux-i586 in home/j3d directory then added i386 folder to usr/lib/jvm/java-6-openjdkjre/lib/i386
1) Window--> Preferences--> User Libraries --> New and added the three .jar files (j3dcore.jar, j3dutils.jar, vecmath.core)
2) Added a native library location to point to usr/lib/jvm/java-6-openjdkjre/lib/i386 where the .so files are
Some sources say try adding the .jar files to your Classpath Variable which didn't fix the problem for me.
I keep getting
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libj3dcore-ogl.so: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libj3dcore-ogl.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1667)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at javax.media.j3d.NativePipeline$1.run(NativePipeline.java:231)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.j3d.NativePipeline.loadLibrary(NativePipeline.java:200)
at javax.media.j3d.NativePipeline.loadLibraries(NativePipeline.java:157)
at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:987)
at javax.media.j3d.VirtualUniverse.(VirtualUniverse.java:299)
at Hello3d.(Hello3d.java:13)
at Hello3d.main(Hello3d.java:27)
I had the same problems. Most tutorials tell you to assign an new library, but i mixed the Java3D files with the JDK files and re installed eclipse. If this doesn't work use net Beans.