hur*_*own 4 java windows dll swt
我在Internet上找不到SWT尝试编写dll文件的地方.我有一台计算机,其中jar不能运行只因为SWT无法编写DLL.
更新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)
Run Code Online (Sandbox Code Playgroud)
我自己找到了答案.从SWT 3.3开始,您不必再包含本机(DLL)库,因为它们位于jar本身中,并且只要调用SWT库就会解压缩它们.DLL文件从jar解压缩并放在"System.getProperty("user.home")"下的".swt"文件夹中.在我的情况下,问题是System.getProperty("user.home")被设置为"\ ubz01fst\Students\User2010\Com\xxx"这是一个UNC路径并且不可写(这通常发生在公司或组织中)电脑 ).
我不知道为什么计算机中的System.getProperty("user.home")取自Windows的环境变量"HOMESHARE"
解决方案包括使用可写路径更改System.getProperty("user.home"),例如:
System.setProperty("user.home", System.getenv("USERPROFILE"));
Run Code Online (Sandbox Code Playgroud)
在调用任何SWT代码之前.
| 归档时间: |
|
| 查看次数: |
4971 次 |
| 最近记录: |