简体   繁体   English

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

[英]Exporting java program with processing elements to executable jar

I have a java project with processing elements that compiles and runs fine inside of Eclipse, but I need to export it to an executable. 我有一个Java项目,其处理元素可以在Eclipse中编译并正常运行,但是我需要将其导出到可执行文件中。 When I do this via Eclipse's export wizard, it produces a jar, but that jar produces runtime errors when it's double clicked or called from the command line. 当我通过Eclipse的导出向导执行此操作时,它会生成一个jar,但是当双击或从命令行调用该jar时,它将产生运行时错误。 First it was giving me this: 首先,它给了我这个:

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)

So I tried pasting gluegen-rt.dll into the given directory, and then it gave me this error instead: 所以我尝试将gumgen-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)

After some googling, it appears this dependency issue might be a bug with jogl: https://java.net/jira/browse/JOGL-346 but I find it hard to believe that nobody has been able to export any processing applications from Eclipse. 经过一番谷歌搜索之后,似乎这个依赖关系问题可能是jogl的错误: https ://java.net/jira/browse/JOGL-346,但是我很难相信没有人能够从Eclipse导出任何处理应用程序。 There's got to be a way, hasn't there? 一定有办法,不是吗?

Any suggestions? 有什么建议么?

Processing requires native libraries, which it doesn't look like you're including. 处理需要本机库,看起来好像不包括在内。 You need to at least put the JOGL jar for the system you're on, but that won't help you deploy to other systems. 您至少需要为正在使用的系统放置JOGL jar,但这不会帮助您部署到其他系统。

Shameless self-promotion: I wrote a tool that helps you create self-extracting runnable jar files that handle Processing's native libraries automatically so it works on every system: http://StaticVoidGames.com/SvgExe/ 无耻的自我推广:我编写了一个工具,可帮助您创建可自动处理Processing的本机库的自解压可运行jar文件,因此可在每个系统上运行:http: //StaticVoidGames.com/SvgExe/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM