将带有处理元素的java程序导出到可执行jar

时间:2014-04-12 19:57:46

标签: java eclipse export processing executable

我有一个带有处理元素的java项目,可以在Eclipse中编译和运行,但是我需要将它导出到可执行文件中。当我通过Eclipse的导出向导执行此操作时,它会生成一个jar,但是当它被双击或从命令行调用时,该jar会产生运行时错误。首先,它给了我这个:

C:\Users\Rachel\School\MQP>java -jar Simworm14.jar
Catched MalformedURLException: Could not open InputStream for URL 'rsrc:gluegen-
rt-natives-windows-amd64.jar', while addNativeJarLibsImpl(classFromJavaJar class
 com.jogamp.common.os.Platform, classJarURI jar:rsrc:gluegen-rt.jar!/com/jogamp/
common/os/Platform.class, nativeJarBaseName gluegen-rt-natives-windows-amd64.jar
): [ rsrc:gluegen-rt.jar -> rsrc: ] + gluegen-rt-natives-windows-amd64.jar -> sl
im: jar:rsrc:gluegen-rt-natives-windows-amd64.jar!/
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: Can't loa
d library: C:\Users\Rachel\School\MQP\gluegen-rt.dll
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1706)
        at java.lang.Runtime.load0(Runtime.java:770)
        at java.lang.System.load(System.java:1003)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoad
erBase.java:551)
        at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.ja
va:64)
        at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNIL
ibLoaderBase.java:96)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.j
ava:414)
        at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrar
y(DynamicLibraryBundle.java:388)
        at com.jogamp.common.os.Platform$1.run(Platform.java:203)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.jogamp.common.os.Platform.<clinit>(Platform.java:173)
        at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:82)
        at processing.opengl.PJOGL.initSurface(PJOGL.java:250)
        at processing.opengl.PGraphicsOpenGL.initPrimary(PGraphicsOpenGL.java:62
44)
        at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:16
25)
        at processing.core.PApplet.run(PApplet.java:2177)
        at java.lang.Thread.run(Thread.java:662)

所以我尝试将gluegen-rt.dll粘贴到给定目录中,然后它给了我这个错误:

C:\Users\Rachel\School\MQP>java -jar Simworm14.jar
Catched MalformedURLException: Could not open InputStream for URL 'rsrc:gluegen-
rt-natives-windows-amd64.jar', while addNativeJarLibsImpl(classFromJavaJar class
 com.jogamp.common.os.Platform, classJarURI jar:rsrc:gluegen-rt.jar!/com/jogamp/
common/os/Platform.class, nativeJarBaseName gluegen-rt-natives-windows-amd64.jar
): [ rsrc:gluegen-rt.jar -> rsrc: ] + gluegen-rt-natives-windows-amd64.jar -> sl
im: jar:rsrc:gluegen-rt-natives-windows-amd64.jar!/
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: C:\Users\
Rachel\School\MQP\gluegen-rt.dll: Can't find dependent libraries
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
        at java.lang.Runtime.load0(Runtime.java:770)
        at java.lang.System.load(System.java:1003)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoad
erBase.java:551)
        at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.ja
va:64)
        at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNIL
ibLoaderBase.java:96)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.j
ava:414)
        at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrar
y(DynamicLibraryBundle.java:388)
        at com.jogamp.common.os.Platform$1.run(Platform.java:203)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.jogamp.common.os.Platform.<clinit>(Platform.java:173)
        at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:82)
        at processing.opengl.PJOGL.initSurface(PJOGL.java:250)
        at processing.opengl.PGraphicsOpenGL.initPrimary(PGraphicsOpenGL.java:62
44)
        at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:16
25)
        at processing.core.PApplet.run(PApplet.java:2177)
        at java.lang.Thread.run(Thread.java:662)

经过一些谷歌搜索后,看来这个依赖性问题可能是jogl:https://java.net/jira/browse/JOGL-346的一个错误,但我发现很难相信没有人能够从Eclipse导出任何处理应用程序。必须有办法,不是吗?

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

处理需要本机库,它看起来不像你所包含的。您至少需要为您所使用的系统安装JOGL jar,但这无助于您部署到其他系统。

无耻的自我推销:我编写了一个工具,可以帮助您创建自动提取的可运行jar文件,自动处理Processing的本机库,以便它可以在每个系统上运行:http://StaticVoidGames.com/SvgExe/