Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

appbundler jogl jnilib dylib one-jar confusio

nyholku
2012-11-24
2013-05-23
  • nyholku
    nyholku
    2012-11-24

    Hi,

    Now this might be JOGL 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

    PS for reference, here is what I've got in my one-jarred .jar file

    nyholkujar tf EazyCNC.jar
    main/main.jar
    .version
    OneJar.class
    com/simontuffs/onejar/Boot$1.class
    com/simontuffs/onejar/Boot$2.class
    com/simontuffs/onejar/Boot$3.class
    com/simontuffs/onejar/Boot.class
    com/simontuffs/onejar/Handler$1.class
    com/simontuffs/onejar/Handler.class
    com/simontuffs/onejar/IProperties.class
    com/simontuffs/onejar/JarClassLoader$1.class
    com/simontuffs/onejar/JarClassLoader$2.class
    com/simontuffs/onejar/JarClassLoader$ByteCode.class
    com/simontuffs/onejar/JarClassLoader$FileURLFactory$1.class
    com/simontuffs/onejar/JarClassLoader$FileURLFactory.class
    com/simontuffs/onejar/JarClassLoader$IURLFactory.class
    com/simontuffs/onejar/JarClassLoader$OneJarURLFactory.class
    com/simontuffs/onejar/JarClassLoader.class
    com/simontuffs/onejar/OneJarFile$1.class
    com/simontuffs/onejar/OneJarFile$2.class
    com/simontuffs/onejar/OneJarFile.class
    com/simontuffs/onejar/OneJarURLConnection.class
    doc/one-jar-license.txt
    META-INF/
    META-INF/MANIFEST.MF
    lib/
    lib/AppleJavaExtensions.jar
    lib/RXTXcomm.jar
    lib/comm.jar
    lib/gluegen.jar
    lib/jna-3.2.5.jar
    lib/jogl-all.jar
    lib/miglayout-3.7.jar
    lib/purejavacomm-0.0.3.jar
    lib/vecmath.jar
    binlib/
    binlib/linux32/
    binlib/linux64/
    binlib/macosx/
    binlib/windows32/
    binlib/windows64/
    binlib/macosx/libgluegen-rt.dylib
    binlib/macosx/libjogl_desktop.dylib
    binlib/macosx/libnativewindow_awt.dylib
    binlib/macosx/libnativewindow_macosx.dylib
    hn:bin nyholku$