我试图学习swt,我使用maven进行所有构建,并使用eclipse进行IDE.当从maven存储库中获取swt jar时,我得到:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3034 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:100)
at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:19)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:112)
at wenzlick.test.swt.main.Main.main(Main.java:30)
Run Code Online (Sandbox Code Playgroud)
有没有人成功获得使用maven构建和运行的swt应用程序?
编辑:我做了一点研究,发现了问题.看看我下面的帖子
我正在尝试构建一个(几乎)独立于平台的 SWT Maven 原型来构建 SWT 应用程序。它应该根据平台自动下载所需的 SWT 库。到目前为止,这是我的pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.mackaz</groupId>
<artifactId>swttest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swt.version>3.7</swt.version>
</properties>
<dependencies>
<dependency>
<groupId>${swt.groupId}</groupId>
<artifactId>${swt.artifactId}</artifactId>
<version>${swt.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<debug>true</debug>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>mac</id>
<activation>
<os>
<name>mac os x</name>
</os>
</activation>
<properties>
<swt.groupId>org.eclipse.swt.carbon</swt.groupId>
<swt.artifactId>macosx</swt.artifactId>
</properties>
</profile>
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<swt.groupId>org.eclipse.swt.win32.win32</swt.groupId>
<swt.artifactId>x86</swt.artifactId>
</properties>
</profile>
<profile>
<id>linux</id>
<activation>
<os>
<family>linux</family>
</os>
</activation>
<properties>
<swt.groupId>org.eclipse.swt.gtk.linux</swt.groupId>
<swt.artifactId>x86_64</swt.artifactId>
</properties>
</profile> …Run Code Online (Sandbox Code Playgroud) 我想打开一个FileDialog窗口进入用户主文件夹(即/ home/user或/ Users/unsername)
我使用System.getProperty读取用户主文件夹:
String homefolder = System.getProperty(user.home);
Run Code Online (Sandbox Code Playgroud)
变量包含正确的主文件夹.但是当我在FileDialog中设置filterpath时,它打开(在linux中)只有/ home级别没有进入用户主目录.
这是源代码:
FileDialog dialog = new FileDialog(shell);
dialog.setText("Choose a certificate");
String platform = SWT.getPlatform();
String homefolder = System.getProperty("user.home");
dialog.setFilterPath(homefolder);
Run Code Online (Sandbox Code Playgroud)
任何的想法?这是一个截图:
