我有一个Ant
构建(请参见下面的build.xml
),该构建可以在Eclipse
中按我的期望进行编译和运行。
但是,当我通过命令行(java -jar swtgui.jar
)运行构建时,出现以下错误:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Layout
at java.lang.Class.getDeclaredMethods0(Native Method)
...
etc
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project default="run" name="My Project ">
<target name="run" depends="createjar">
<java classname="com.company.program.project.MyMainClass">
<classpath path="staging">
<fileset dir="C:\COMPANY\Eclipse\3.6-64\plugins">
<include name="org.eclipse.swt.*.jar" />
</fileset>
</classpath>
</java>
</target>
<target name="createjar" depends="compile">
<jar destfile="./builds/jars/swtgui.jar" basedir="staging" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="com.company.program.project.MyMainClass" />
</manifest>
<fileset dir="C:\COMPANY\Eclipse\3.6-64\plugins\" includes="org.eclipse.swt.win32.win32.x86_64_3.6.0.v3650b.jar" />
</jar>
</target>
<target name="compile">
<javac includeantruntime="false" srcdir="./src" destdir="staging">
<classpath>
<fileset dir="C:\COMPANY\Eclipse\3.6-64\plugins">
<include name="org.eclipse.swt.*.jar" />
</fileset>
</classpath>
</javac>
</target>
<record name="./MyMainClass.log" loglevel="verbose" action="start"/>
该错误对我来说没有意义,因为我为compile
目标指定了与createjar
目标相同的SWT库路径。
如果为compile
目标找到了SWT库,为什么没有为createjar
目标找到它?