我正在尝试为我的项目创建一个使用JOGL的可执行jar。以前没有JOGL,使用maven-assembly-plugin很容易。我的申请表中有以下内容:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.jbox2d.testbed.framework.jogl.JoglTestbedMain</mainClass>
</manifest>
</archive>
</configuration>
在非jogl项目中,这会生成一个可执行的好jbox2d-testbed-2.2.1.2-SNAPSHOT-jar-with-dependencies
(当然,其中包含不同的主类)。
JOGL项目在Eclipse中使用mavin插件运行得很好,我包含了here in the wiki描述的jogl依赖项。但是,当我在此项目上使用程序集插件并启动jbox2d-testbed-jogl-1.0.2-SNAPSHOT-jar-with-dependencies.jar
时,我收到以下错误:
Catched FileNotFoundException: /Users/dmurph/Projects/jbox2d/jbox2d-testbed-jogl/target/jbox2d-testbed-jogl-1.0.2-SNAPSHOT-jar-with-dependencies-natives-macosx-universal.jar (No such file or directory), while addNativeJarLibsImpl(classFromJavaJar class com.jogamp.common.os.Platform, classJarURI jar:file:/Users/dmurph/Projects/jbox2d/jbox2d-testbed-jogl/target/jbox2d-testbed-jogl-1.0.2-SNAPSHOT-jar-with-dependencies.jar!/com/jogamp/common/os/Platform.class, nativeJarBaseName jbox2d-testbed-jogl-1.0.2-SNAPSHOT-jar-with-dependencies-natives-macosx-universal.jar): [ file:/Users/dmurph/Projects/jbox2d/jbox2d-testbed-jogl/target/jbox2d-testbed-jogl-1.0.2-SNAPSHOT-jar-with-dependencies.jar -> file:/Users/dmurph/Projects/jbox2d/jbox2d-testbed-jogl/target/ ] + jbox2d-testbed-jogl-1.0.2-SNAPSHOT-jar-with-dependencies-natives-macosx-universal.jar -> slim: jar:file:/Users/dmurph/Projects/jbox2d/jbox2d-testbed-jogl/target/jbox2d-testbed-jogl-1.0.2-SNAPSHOT-jar-with-dependencies-natives-macosx-universal.jar!/
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /System/Library/Frameworks/gluegen-rt.Framework/gluegen-rt
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1854)
at java.lang.Runtime.load0(Runtime.java:795)
at java.lang.System.load(System.java:1062)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:551)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:96)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:414)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(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 org.jbox2d.testbed.framework.jogl.JoglPanel.<init>(JoglPanel.java:52)
at org.jbox2d.testbed.framework.jogl.JoglTestbedMain.main(JoglTestbedMain.java:62)
当我解压缩jar时,我会看到JOGL所需的所有dll和jnilib库,所以我需要做些什么才能让它工作?我知道JOGL使用一个单独的jar系统,我是否需要更改程序集插件的行为,以便它可以正确生成额外的jar?
如果您愿意,可以抓住我的项目并尝试一下,它位于https://github.com/dmurph/jbox2d
谢谢!
答案 0 :(得分:1)
根据JOGL FAQ,您需要将本机库放在胖罐中的特定位置。看起来你在Mac上,所以你需要将你的本地库放在你的jar 中的目录中:
natives/macosx-universal/
如@gouessej所述,here is a complete list of supported architectures and required directories。
我认为您需要创建自定义Assembly Descriptor:
https://maven.apache.org/plugins/maven-assembly-plugin/assembly.html
编写自己的描述符将允许您将罐放置在特定位置,以获得所需的包装。
答案 1 :(得分:0)
您必须遵循精确的语义规则才能使其正常工作,以便GlueGen能够在JAR中找到本机库,提取它们并加载它们: http://forum.jogamp.org/Packaging-JOGL-projects-to-be-cross-platform-tp4031261p4031286.html