How to change gtk to cocona, when SWT load native library? - java

I do not know why SWT load libswt-gtk-4332.jnilib. I used mac os and built SWT/Jface Project with Runnable Jar. I run Runnable Jar but I failed. Outputed the error log.
I executed it in mac:
java -jar -verbose threed-1.0-SNAPSHOT.jar
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-gtk-4332 in java.library.path: [/Users/admin/Library/Java/Extensions, /Library/Java/Extensions, /Network/Library/Java/Extensions, /System/Library/Java/Extensions, /usr/lib/java, .]
no swt-gtk in java.library.path: [/Users/admin/Library/Java/Extensions, /Library/Java/Extensions, /Network/Library/Java/Extensions, /System/Library/Java/Extensions, /usr/lib/java, .]
Can't load library: /var/root/.swt/lib/macosx/x86_64/libswt-gtk-4332.jnilib
Can't load library: /var/root/.swt/lib/macosx/x86_64/libswt-gtk.jnilib
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
at org.eclipse.swt.widgets.Widget.isValidSubclass(Unknown Source)
at org.eclipse.swt.widgets.Decorations.checkSubclass(Unknown Source)
at org.eclipse.swt.widgets.Shell.<init>(Unknown Source)
at org.eclipse.swt.widgets.Shell.<init>(Unknown Source)
at org.eclipse.jface.window.Window.createShell(Window.java:487)
at org.eclipse.jface.window.Window.create(Window.java:430)
at org.eclipse.jface.window.Window.open(Window.java:790)
at PlayerTableTree.run(Application.kt:20)
at ApplicationKt.main(Application.kt:303)
at ApplicationKt.main(Application.kt)

Solved. I used Jzy3d Library. Jzy3d SWT injected the gtk swt...
Thx for #greg-44, your comment was hint.

Related

libopencv_java342.dll: Can't find dependent libraries?

I am trying to run a face recognition project which uses opencv and its contrib function.
I have imported the opencv_342.jar as user libraries. and give the native library location to the folder where all the dll files are.
It is still program giving error of
Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\opencv_build\bin\libopencv_java342.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.demo.HelloWorld.main(HelloWorld.java:9)
I don't know why It is unable to find other libraries which dll files are in bin folder

How to specify the correct DLL for SWT when running main?

I'm getting an error where my maven build works fine (using mvn install: the produced executable runs in Windows), but when I try to run main directly from IntelliJ, it is looking for SWT's GTK dlls, which is of course not correct:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-gtk-4528 in java.library.path
no swt-gtk in java.library.path
Can't load library: C:\Users\brandon\.swt\lib\win32\x86_64\swt-gtk-4528.dll
Can't load library: C:\Users\brandon\.swt\lib\win32\x86_64\swt-gtk.dll
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
at edu.cornell.ansci.dairy.econ.ui.MainWindow$.main(MainWindow.scala:175)
at edu.cornell.ansci.dairy.econ.ui.MainWindow.main(MainWindow.scala)
In fact the actual file contents of the directory look correct, but this is not what is being looked for:
brandon#DESKTOP-MU8LD7O:/mnt/c/Users/brandon/.swt/lib/win32/x86_64$ ls
swt-gdip-win32-4528.dll swt-win32-4528.dll
Here is an image of the run configuration in Intellij (Default JDK is Zulu - maybe I should try to install another?):

Can't obtain inputstream

I'm trying to work with the tess4j library, but I keep getting the error:
java.lang.UnsatisfiedLinkError: Unable to load library 'tesseract':
Can't obtain InputStream for linux-x86-64/libtesseract.so at
com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271) at
com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398) at
com.sun.jna.Library$Handler.(Library.java:147) at
com.sun.jna.Native.loadLibrary(Native.java:412) at
com.sun.jna.Native.loadLibrary(Native.java:391) at
net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(Unknown
Source) at net.sourceforge.tess4j.TessAPI.(Unknown Source) at
net.sourceforge.tess4j.Tesseract.init(Unknown Source) at
net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) at
net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) at
net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) at
I am trying to package the tesseract.so executable in my JAR. I saw the example here: http://tess4j.sourceforge.net/tutorial/ and it seems to suggest I can just put it in my build path. Any help would be appreciated. I've tried building it against 32 and 64 bit JRE.

SWT: Running an application developed on OSX in Windows

I have an SWT application that I've developed on OSX, so it contains the Mac version of the SWT libraries.
Now I need to run this application on a Windows machine. I export the application to a .jar file, but when I attempt to execute the jar in Windows, I get:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-cocoa-4236 in java.library.path
no swt-cocoa in java.library.path
Can't load library: \\psf\Home\.swt\lib\win32\x86\swt-cocoa-4236.dll
Can't load library: \\psf\Home\.swt\lib\win32\x86\swt-cocoa.dll
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
at display.StoragePickupDisplay.open(StoragePickupDisplay.java:70)
at display.StoragePickupDisplay.main(StoragePickupDisplay.java:58)
... 5 more
I have added the Windows version of SWT libraries but that didn't make a difference. I need the Mac libraries to be in there for continued development. How can I get around this?
You have to add the correct SWT.jar to the classpath. You can download them here.
If you are deploying for Windows, you will have to bundle the swt jar for Windows (either 32bit or 64bit depending on the system).
If you want to create an application that runs on all platforms, have a look at this post:
Create cross platform Java SWT Application

Where does SWT write dll files on windows?

I cannot find on the Internet where SWT tries to write the dll files. I have a computer where the jar does not run only because SWT cannot write DLLs.
UPDATE 1
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-win32-3738 in java.library.path
no swt-win32 in java.library.path
Can't load library: \\ubz01fst\Students\User2010\Com\xxx\swt-win32-3738.dll
Can't load library: \\ubz01fst\Students\User2010\Com\xxx\swt-win32.dll
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
at install.Main.main(Main.java:162)
I find out the answer myself.
Since SWT 3.3 you don't have to include the native (DLL) library anymore, because they are in the jar itself and they are unpacked as soon as the SWT library is called.
The DLL files are unpacked from the jar and placed in the ".swt" folder under your "System.getProperty("user.home")".
In my case the problem was that System.getProperty("user.home") is set to "\ubz01fst\Students\User2010\Com\xxx" which is a UNC path and that is not writable ( this often happen in companies or organizations computers ).
I donno for which reason the System.getProperty("user.home") in computers is taken from the environment variable "HOMESHARE" of Windows
The solution consists in changing the System.getProperty("user.home") with a writable path, for example:
System.setProperty("user.home", System.getenv("USERPROFILE"));
before calling any SWT code.
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.
Regards.

Categories

Resources