我用 Scala 和 JOGL 创建了一个 OpenGL 项目,并试图使用 sbt 和 one-jar 插件将它打包成一个 .jar 文件。
.jar 的创建没有任何错误,但是当我尝试运行 .jar 时,我收到一条错误消息,指出在主 .jar 中找不到 JOGL .jar。我跑去jar tf
看主罐子里的东西,我看到里面“丢失”的罐子。
“失踪”的罐子是gluegen-rt-natives-windows-amd64.jar
这是我得到的错误:
Catched FileNotFoundException: \target\scala-2.9.2\rings_2.9.2-1.0-one-jar.jar (
The system cannot find the path specified), while TempJarCache.bootstrapNativeLi
b() of jar:file:/target/scala-2.9.2/rings_2.9.2-1.0-one-jar.jar!/lib/gluegen-rt-
natives-windows-amd64.jar!/ (file:/target/scala-2.9.2/rings_2.9.2-1.0-one-jar.ja
r!/lib/ + gluegen-rt-natives-windows-amd64.jar)
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.simontuffs.onejar.Boot.run(Boot.java:340)
at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoad
erBase.java:442)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.ja
va:59)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNIL
ibLoaderBase.java:90)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.j
ava:328)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrar
y(DynamicLibraryBundle.java:390)
at com.jogamp.common.os.Platform.loadGlueGenRTImpl(Platform.java:251)
at com.jogamp.common.os.Platform.access$000(Platform.java:57)
at com.jogamp.common.os.Platform$1.run(Platform.java:186)
at com.jogamp.common.os.Platform$1.run(Platform.java:183)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:183)
at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:82)
at com.bwroga.opengl.GLEnvironment.createCanvas(GLEnvironment.scala:63)
at com.bwroga.opengl.GLEnvironment.<init>(GLEnvironment.scala:18)
at Environment.<init>(Main.scala:24)
at Main$.<init>(Main.scala:12)
at Main$.<clinit>(Main.scala)
at Main.main(Main.scala)
... 6 more
这是来自的输出jar tf
:
META-INF/MANIFEST.MF
com/
com/simontuffs/
com/simontuffs/onejar/
doc/
lib/
main/
com/simontuffs/onejar/JarClassLoader$2.class
lib/scala-library.jar
lib/gluegen-rt-natives-linux-amd64.jar
.version
lib/jogl-all-natives-macosx-universal.jar
com/simontuffs/onejar/JarClassLoader$OneJarURLFactory.class
com/simontuffs/onejar/JarClassLoader.class
com/simontuffs/onejar/OneJarFile.class
boot-manifest.mf
com/simontuffs/onejar/OneJarURLConnection.class
lib/jogl-all-natives-linux-amd64.jar
lib/gluegen-rt-natives-windows-i586.jar
com/simontuffs/onejar/Boot$1.class
com/simontuffs/onejar/IProperties.class
com/simontuffs/onejar/Handler.class
com/simontuffs/onejar/Handler$1.class
lib/jogl-all.jar
main/rings_2.9.2-1.0.jar
com/simontuffs/onejar/Boot$3.class
lib/commons-lang-2.6.jar
doc/one-jar-license.txt
lib/gluegen-rt-natives-macosx-universal.jar
OneJar.class
com/simontuffs/onejar/OneJarFile$1.class
com/simontuffs/onejar/JarClassLoader$1.class
com/simontuffs/onejar/JarClassLoader$IURLFactory.class
com/simontuffs/onejar/JarClassLoader$ByteCode.class
lib/jogl-all-natives-windows-amd64.jar
com/simontuffs/onejar/JarClassLoader$FileURLFactory$1.class
com/simontuffs/onejar/JarClassLoader$FileURLFactory.class
lib/jogl-all-natives-windows-i586.jar
lib/gluegen-rt.jar
com/simontuffs/onejar/Boot$2.class
lib/jogl-all-natives-linux-i586.jar
com/simontuffs/onejar/Boot.class
lib/gluegen-rt-natives-linux-i586.jar
lib/gluegen-rt-natives-windows-amd64.jar
com/simontuffs/onejar/OneJarFile$2.class