我是Java&日食。我有一个带有对话框的基于窗口的应用程序,可以在IDE内部正常工作。但是,当我尝试导出JAR以使其在IDE外部可执行(因此可再发行)时,我使用以下命令执行它:
java -jar MyLibrary-app.jar
我得到例外:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-win32-4427 in java.library.path
no swt-win32 in java.library.path
Can't load library: C:\Users\jay.imerman\.swt\lib\win32\x86\swt-win32-4427.dll
Can't load library: C:\Users\jay.imerman\.swt\lib\win32\x86\swt-win32.dll
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:327)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:236)
at org.eclipse.swt.internal.C.<clinit>(C.java:21)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:138)
at org.jimerman.MyLibrary.MainWindow.open(MainWindow.java:51)
at org.jimerman.MyLibrary.MainWindow.main(MainWindow.java:40)
我不知道导出JAR和Runnable JAR之间的区别是什么,我尝试了两者。在前者中,我还尝试从swt项目中包含src,以及我引用的另一个Java类库项目。我习惯于Visual Studio和Setup项目,它检测依赖项并收集部署的引用。我错过了什么?如果我使用像Maven这样的东西,我怎么去学习所有的术语和概念,甚至理解它意味着什么以及我需要什么来构建可再发行文件?
答案 0 :(得分:0)
您可以选择在eclipse中导出到runnable-jar并保存ant.xml。它应该看起来像
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_run_jar" name="Create Runnable Jar for Project MyLibrary-app">
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
<!--ANT 1.7 is required -->
<target name="create_run_jar">
<jar destfile="MyLibrary-app" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="MainClass"/>
<attribute name="Class-Path" value="."/>
</manifest>
<fileset dir="bin"/>
<zipfileset excludes="META-INF/*.SF" src="{Eclipse_HOME}/plugins/org.eclipse.swt.win32.win32.x86_x.x.x.vxxxxa.jar"/>
</jar>
</target>
</project>