Login  Register

appbundler jogl jnilib dylib one-jar confusion

Posted by nyholku on Nov 24, 2012; 11:07am
URL: https://forum.jogamp.org/appbundler-jogl-jnilib-dylib-one-jar-confusion-tp4027169.html

Hi,

Now this might be one-jar or Mac Java 7 problem so I will be
pestering those lists too but this is so confusing that
I want to left no stone interned...

Ok, to the business, here it the weirdest thing that
has been bothering me on and off for a few weeks.

I'm developing an application that uses OpenGL via
JOGL. I package it using one-jar and then use launch4j
and appbundler to turn it into a .exe and .app file/bundle.

I'm pretty sure this was working flawlessly some months ago,
I might believe I had dreamed but there is this dialog
from my in the web so I must have had it working previously:

http://stackoverflow.com/questions/8943804/launch4j-onejar-packed-exe-file-corrupted

Anyway, now all of a sudden when I came back to this
project after summer, the .app refused to start, it launched
and but nothing happened. Starting from Terminal I saw
that it had trouble loading jnilib's for JOGL.

In the interim time what has changed is that I've upgraded
to Java 7 and Mountain Lion (and Retina MacBook Pro).

Figuring this might be that JOGL/jogamp or one-jar had gone stale
I've upgraded to the latest.

Now here were it gets confusing.

In Eclipse, to be able to launch the app it is enough to include:

gluegen-rt-natives-macosx-universal.jar
gluegen-rt.jar
gluegen.jar
jogl.all.jar

in the project build path. Works like a charm.

To be able to use one-jar I need to include not only:

gluegen-rt.jar
gluegen.jar
jogl.all.jar

but the native libraries unpacked from the jar:

libgluegen.rt.dylib
libjogl_desktop.dylib
libnativewindow_awt.dylib
libnativewindow_macosx.dylib

and interestingly/confusingly these need to be .dylib
not .jnilip although the jogamp distrubutes them as
.jnilib and apparently Eclipse can figure this out
when those files are in the gluegen-rt-natives-macosx-universal.jar

What's going on?

Anyway with above I can get one-jar to produce a single
jar that works fine, apart from having the correct process
name for the application and a nice icon.

So I apply appbundler to that jar and turn it into a .app bundle
and again I'm back where I started:

nyholku$ EazyCNC.app/Contents/MacOS/JavaApplicationStub
Loading configuration from /Users/nyholku/EazyCNC/EazyCNC-Mach-Config.ecnc
Catched UnknownHostException: Users, while TempJarCache.bootstrapNativeLib() of jar:file://Users/nyholku/EazyCNCProject/bin/EazyCNC.app/Contents/Resources/Java/EazyCNC.jar!/lib/gluegen-natives-macosx-universal.jar!/ (file://Users/nyholku/EazyCNCProject/bin/EazyCNC.app/Contents/Resources/Java/EazyCNC.jar!/lib/ + gluegen-natives-macosx-universal.jar)
java.lang.reflect.InvocationTargetException
        at java.awt.EventQueue.invokeAndWait(EventQueue.java:1111)
retrigCompile eazycnc.GCodeEditorPanel$5.run(GCodeEditorPanel.java:173)
......
        at apple.launcher.LaunchRunner.run(LaunchRunner.java:116)
        at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:51)
        at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)
Caused by: java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1045)
...

So several weird things going on here, any ideas to go forward would
be appreciated.

To recap:

Why Eclipse works with just the .jar files and/or why
the one-jar classloader does not?

Should the native libraries be .jnilib or .dylib? I've
always used .jnilib when I've called native code from Java?

Why the appbundler packaged working .jar fails to load
the native libraries?



br Kusti