Can't find/load swt-gtk - java

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.

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.

Can't find the dependent library for mavenized JCUDA in Eclipse

I am trying to setup mavenized JCUDA for a project that I am working on and am running into issues with telling java where to locate the library files.
Setting up and getting maven to build the .jar and .dll files has worked fine, I can see the correctly named .dll files in project\target\lib and I am setting my native library location to this folder.
The error I get when trying to run one of the programs from JCUDA JCublasSample.java (www.jcuda.org/samples/JCublasSample.java) is:
Creating input data... Performing Sgemm with Java... Performing Sgemm
with JCublas...
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not
load the native library.
Error while loading native library "JCublas-windows-x86_64" with base
name "JCublas" Operating system name: Windows 7 Architecture :
amd64 Architecture bit size: 64
Stack trace from the attempt to load the library as a resource:
java.lang.NullPointerException: No resource found with name
'/lib/JCublas-windows-x86_64.dll'
at jcuda.LibUtils.loadLibraryResource(LibUtils.java:149) at
jcuda.LibUtils.loadLibrary(LibUtils.java:83) at
jcuda.jcublas.JCublas.initialize(JCublas.java:93) at
jcuda.jcublas.JCublas.(JCublas.java:81) at
JCublasSample.sgemmJCublas(JCublasSample.java:64) at
JCublasSample.testSgemm(JCublasSample.java:49) at
JCublasSample.main(JCublasSample.java:25)
Stack trace from the attempt to load the library as a file:
java.lang.UnsatisfiedLinkError:
C:\Users\kristoffer.bernhem\git\SMlocalizer\target\lib\JCublas-windows-x86_64.dll:
Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method) at
java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857) at
java.lang.Runtime.loadLibrary0(Runtime.java:870) at
java.lang.System.loadLibrary(System.java:1122) at
jcuda.LibUtils.loadLibrary(LibUtils.java:94) at
jcuda.jcublas.JCublas.initialize(JCublas.java:93) at
jcuda.jcublas.JCublas.(JCublas.java:81) at
JCublasSample.sgemmJCublas(JCublasSample.java:64) at
JCublasSample.testSgemm(JCublasSample.java:49) at
JCublasSample.main(JCublasSample.java:25) at
jcuda.LibUtils.loadLibrary(LibUtils.java:128) at
jcuda.jcublas.JCublas.initialize(JCublas.java:93) at
jcuda.jcublas.JCublas.(JCublas.java:81) at
JCublasSample.sgemmJCublas(JCublasSample.java:64) at
JCublasSample.testSgemm(JCublasSample.java:49) at
JCublasSample.main(JCublasSample.java:25)
As explained by Guenther, the problem lies in supporting .dll files that are lacking. How would I go about sorting this error out?
This is being run in windows 7 (64bit) and run with JDK1.8.0_91.

Exception in thread "Thread-60" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path

Attempting to build sikuli-slides-1.5.0 with the command "mvn clean install", I am getting the above referenced stack trace. I am using Windows 7 and have attempted the instructions I have come across for various solutions proposed on here to no avail. My Path and CLASSPATH variables for both user and system defined variables include:
"C:\opencv\build\x64\vc10\bin"
and I have restarted my machine multiple times.
In addition, I have added javacv.jar, javacv.windows-x86.jar, javacv.windows-x86_64.jar to my project's build path and have javacv-0.9.jar in my pom.xml. I have also included javacpp-0.9.jar in my pom as well. I can visually see all of the above referenced jars on my build path and can import the jniopencv_core into any of my classes. Any assistance would be greatly appreciated. While executing the JUnit test AutomationExecutorExceptionTest.java, the test fails and creates an orphaned java.exe process that must be manually shut down.
The full stack trace is listed below.
Exception in thread "Thread-60" java.lang.UnsatisfiedLinkError: no jniopencv_core in >java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:410)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.opencv_core.(opencv_core.java:10)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.create(openc
v_core.java:909)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.createFrom(o
pencv_core.java:999)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.createFrom(o
pencv_core.java:971)
at org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.createFrom(o
pencv_core.java:968)
at org.sikuli.core.cv.ImagePreprocessor.createGrayscale(ImagePreprocesso
r.java:43)
at org.sikuli.core.search.TemplateMatcher.findMatchesByGrayscaleAtOrigin
alResolution(TemplateMatcher.java:71)
at org.sikuli.api.ImageTarget.getUnorderedMatches(ImageTarget.java:127)
at org.sikuli.api.DefaultTarget.doFindAll(DefaultTarget.java:128)
at org.sikuli.api.DefaultScreenRegion.findAll(DefaultScreenRegion.java:7
4)
at org.sikuli.slides.api.sikuli.CrossSearchStrategy.testHypotheses(Cross
SearchStrategy.java:85)
at org.sikuli.slides.api.sikuli.CrossSearchStrategy.perform(CrossSearchS
trategy.java:39)
at org.sikuli.slides.api.sikuli.ContextImageTarget.doFindAll(ContextImag
eTarget.java:122)
at org.sikuli.api.DefaultScreenRegion._find(DefaultScreenRegion.java:88)
at org.sikuli.api.DefaultScreenRegion.find(DefaultScreenRegion.java:80)
at org.sikuli.slides.api.actions.TargetAction.execute(TargetAction.java:
26)
at org.sikuli.slides.api.actions.RetryAction.execute(RetryAction.java:51
)
at org.sikuli.slides.api.actions.ParallelAction$Worker.run(ParallelActio
n.java:35)
at java.lang.Thread.run(Thread.java:745)
Your stack trace contains the following line:
Exception in thread "Thread-60" java.lang.UnsatisfiedLinkError: no jniopencv_cor e in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
Notice the space between jniopencv_cor and e?
One of your configuration files contain a space where it shouldn't.
The directions are highly confusing for the javacv files. The issue was that I had to actually explode the contents of the jar file and expose the DLLs in the directory. The instructions packaged with the jars of javacv instructed me to simply place the binaries on the classpath.
I had the same problem and I solved it by adding the following dependency in my Maven project for Sikuli Slides 1.5.1:
GroupId: org.bytedeco.javacpp-presets
AritfactId: opencv
Version: 2.4.9-0.9
Type: jar
Classifier: windows-x86_64
In my case I was using Windows 7 64-bit. After adding this dependency I was able to successfully build Sikuli Slides.

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

When i'm trying to load the .so file from the Java, i'm getting error like this.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no yeslib.so in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at com.rct.micros.util.GetCustClass.getScratchCode(GetCustClass.java:76)
at com.rct.micros.util.GetCustClass.main(GetCustClass.java:39)
I have tried System.load(absoulte path) and System.loadLibrary(sofilename). Both are giving the same error. When i copy this so file into usr/lib/jvm package, it is working..
can anyone help how to get this solved using Java. i'm running on linux box.
It's possible that the library is on your path, but it can't be loaded for some other reason.
A trick I've used to debug problems like this is to run java -Xrunsofilename
-Xrun is the JVM option to load JVMPI libraries (the old profiling interface). If it succeeds, it will load the library and complain that it's not an agent library. But if it fails (hopefully!) it will print an error message. This is usually a more descriptive error message than what you get from the UnsatisfiedLinkError.

no usbJava in java.library.path

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.

Categories