windows SWT在windows上哪里写dll文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8156905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:29:16  来源:igfitidea点击:

Where does SWT write dll files on windows?

javawindowsdllswt

提问by hurtledown

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.

我在 Internet 上找不到 SWT 尝试写入 dll 文件的地方。我有一台 jar 不能运行的计算机,因为 SWT 无法编写 DLL。

UPDATE 1

更新 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)

回答by hurtledown

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 ).

我自己找出答案。从 SWT 3.3 开始,您不必再包含本机 (DLL) 库,因为它们位于 jar 本身中,并且一旦调用 SWT 库就会解压。DLL 文件从 jar 中解压并放置在“System.getProperty(“user.home”)”下的“.swt”文件夹中。在我的例子中,问题是 System.getProperty("user.home") 设置为 "\ubz01fst\Students\User2010\Com\xxx",这是一个 UNC 路径并且不可写(这通常发生在公司或组织中)电脑 )。

I donno for which reason the System.getProperty("user.home") in computers is taken from the environment variable "HOMESHARE" of Windows

我不知道为什么计算机中的 System.getProperty("user.home") 是从 Windows 的环境变量 "HOMESHARE" 中获取的

The solution consists in changing the System.getProperty("user.home") with a writable path, for example:

解决方案包括使用可写路径更改 System.getProperty("user.home"),例如:

System.setProperty("user.home", System.getenv("USERPROFILE"));

before calling any SWT code.

在调用任何 SWT 代码之前。

回答by Charles

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.

好的,我找到了解决方案。问题是关于 dll 的生成。我使用的是 3.7m5 版本,我下载了以前的版本 (3.7) 并且应用程序运行正常。

Regards.

问候。