简体   繁体   中英

Using the maven assembly plugin with JOGL to create executable jar

I'm trying to create an executable jar for my project that uses JOGL . Previously without JOGL this was easy with the maven-assembly-plugin. I have the following in my application pom:

<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>

In the non-jogl project this generates a nice jbox2d-testbed-2.2.1.2-SNAPSHOT-jar-with-dependencies that is executable (with a different main class in there, of course).

The JOGL project runs just fine in Eclipse with the mavin plugin, I included the jogl dependencies as described here in the wiki . However, when I use the assembly plugin on this project and launch the jbox2d-testbed-jogl-1.0.2-SNAPSHOT-jar-with-dependencies.jar I get the following errors:

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)

When I decompress the jar, I see all of the required dll and jnilib libraries for JOGL, so is there something extra I need to be doing to get this to work? I know that JOGL uses a separate-jar system, do I need to change the behavior of the assembly plugin so it can generate the extra jars correctly?

You can grab my project and try it out if you like, it's at https://github.com/dmurph/jbox2d

Thanks!

According to the JOGL FAQ , you need to place your native libraries in specific locations within the fat jar. It looks like you are on a Mac, so you need to place your native libraries in this directory in your jar :

natives/macosx-universal/

As mentioned by @gouessej, here is a complete list of supported architectures and required directories .

I think you will need to create a custom Assembly Descriptor :

https://maven.apache.org/plugins/maven-assembly-plugin/assembly.html

Writing your own descriptor will allow you to place the jars in specific locations, to get the packaging you need.

您必须遵循精确的语义规则以使其起作用,以便GlueGen能够在JAR中定位本机库,提取它们并加载它们: http : //forum.jogamp.org/Packaging-JOGL-projects-to-是跨平台,tp4031261p4031286.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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