我试图运行我的java项目(两个程序,服务器和客户端)在ant。这是我的build。xml
<project name="myproject" default="run" basedir=".">
<description>Client Server gui project</description>
<property name="srcdirserver" location="src/src_server"/>
<property name="srcdirclient" location="src/src_client"/>
<property name="lib" location="lib"/>
<property name="build" location="build"/>
<property name="buildserver" location="build/server"/>
<property name="buildclient" location="build/client"/>
<property name="dest_server" location="dest-server"/>
<property name="dest_client" location= "dest-client"/>
<property name="examples" location="examples"/>
<property name="doc" location="doc"/>
<!-- CLEAN -->
<target name="clean">
<delete dir="${build}"/>
<delete dir="${dest_server}"/>
<delete dir="${dest_client}"/>
</target>
<!-- COMPILE (Dummy)-->
<target name="compile" depends="clean,compileserver,compileclient,jarserver,jarclient,documentation">
</target>
<!-- DOCUMENTATION -->
<target name="documentation">
<javadoc sourcepath="${srcdirserver}" destdir="${doc}" encoding="UTF-8" charset="UTF-8"></javadoc>
</target>
<!-- COMPILE (Server code)-->
<target name="compileserver" depends="clean">
<mkdir dir="${buildserver}"/>
<javac includeantruntime="false"
srcdir="${srcdirserver}"
destdir="${buildserver}"
encoding="UTF-8"
classpath="${src}"/>
</target>
<!-- COMPILE (Client code)-->
<target name="compileclient" depends="clean">
<mkdir dir="${buildclient}"/>
<javac includeantruntime="false"
srcdir="${srcdirclient}"
destdir="${buildclient}"
encoding="UTF-8"
classpath="${lib}/swt.jar:${src}"/>
</target>
<!-- BUILD JAR (server) -->
<target name="jarserver" depends="clean,compileserver">
<mkdir dir="${dest_server}"/>
<jar destfile="${dest_server}/myserver.jar"
basedir="${buildserver}">
<manifest>
<attribute name="Main-Class"
value="game_server.main.Init"/>
</manifest>
</jar>
<mkdir dir="${dest_server}/examples"/>
<copy todir="${dest_server}/examples" >
<fileset dir="${examples}" includes="**"/>
</copy>
</target>
<!-- BUILD JAR (client) -->
<target name="jarclient" depends="clean,compileclient">
<mkdir dir="${dest_client}"/>
<jar destfile="${dest_client}/myclient.jar"
basedir="${buildclient}">
<manifest>
<attribute name="Main-Class"
value="game_client.main.Gui"/>
<attribute name="Class-Path"
value="lib/swt.jar"/>
</manifest>
</jar>
<mkdir dir="${dest_client}"/>
<mkdir dir="${dest_client}/lib"/>
<copy file="${lib}/swt.jar"
todir="${dest_client}/lib"/>
</target>
<!-- RUN -->
<target name="run" depends="compile,jarserver,jarclient">
<parallel>
<java jar="${dest_server}/myserver.jar" dir="${dest_server}" fork="true"/>
<java jar="${dest_client}/myclient.jar" dir="${dest_client}" fork="true"/>
</parallel>
</target>
</project>
服务器工作正常,但客户端与gui被编译/归档到jar成功,但当我运行它它抛出这个错误:/编辑:我发现我使用了错误的swt.jar版本,我现在下载正确,但仍然得到类似的错误:/
run:
[java] OpenJDK 64-Bit Server VM warning: You have loaded library /home/blackened/.swt/lib/linux/x86_64/libswt-gtk-4332.so which might have disabled stack guard. The VM will try to fix the stack guard now.
[java] It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
[java] Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
[java] no swt-gtk-4332 in java.library.path
[java] no swt-gtk in java.library.path
[java] Can't load library: /home/blackened/.swt/lib/linux/x86_64/libswt-gtk-4332.so
[java] Can't load library: /home/blackened/.swt/lib/linux/x86_64/libswt-gtk.so
[java] /home/blackened/.swt/lib/linux/x86_64/libswt-gtk-4332.so: /home/blackened/.swt/lib/linux/x86_64/libswt-gtk-4332.so: Kódovanie dát v ELF súbore nie je little-endian (Possible cause: endianness mismatch)
[java]
[java] at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
[java] at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
[java] at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
[java] at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
[java] at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
[java] at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
[java] at game_client.main.Gui.open(Unknown Source)
[java] at game_client.main.Gui.main(Unknown Source)
[java] Java Result: 1
我使用Fedora 18(球形牛)操作系统。
在我看来,SWT正在寻找这两个jar的32位版本,但从路径中的x86_64判断,您已经安装的是64位版本。
同时,你说你在Fedora上,但它试图加载似乎是windows相关的jar文件。
' unsatisfted link'错误可能是由于它试图查找不存在的dll,而不是Linux上应该查找的。so文件。
这可能有帮助:http://www.eclipse.org/swt/faq.php missingdll