Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
like image 688
hurtledown Avatar asked Nov 16 '11 18:11

hurtledown


1 Answers

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.

like image 95
hurtledown Avatar answered Oct 09 '22 18:10

hurtledown