Move to native jar: nearly there, but not quite

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Move to native jar: nearly there, but not quite

LordSmoke
Greetings. As mentioned in another post, I am back in semi-seclusion for the next two weeks working feverishly on my app and jogl2.

My first order of business was to shift to the fat jar distribution instead of the user-installed native libraries. The wiki helped me figure out the principle, and I have met with some success. That is, I removed the native libraries from my system, redefined my JOGL2 lib (in Netbeans) to include the desired native jars, and rebuild. It works fine from my Netbeans IDE.

I use the following code I grabbed from somewhere to package all the libraries into a single jar for distribution:


<target name="package-for-store" depends="jar">

       
        <property name="store.jar.name" value="my_app"/>


       

        <property name="store.dir" value="store"/>
        <property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>

        <echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>

        <delete dir="${store.dir}"/>
        <mkdir dir="${store.dir}"/>

        <jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
            <zipgroupfileset dir="dist" includes="*.jar"/>
            <zipgroupfileset dir="dist/lib" includes="*.jar"/>

            <manifest>
                <attribute name="Main-Class" value="${main.class}"/>
            </manifest>
        </jar>

        <zip destfile="${store.jar}">
            <zipfileset src="${store.dir}/temp_final.jar"
            excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
        </zip>

        <delete file="${store.dir}/temp_final.jar"/>

    </target>

Alas, the resulting jar gives the following error at startup:

Catched: error in opening zip file
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class javax.media.opengl.GLProfile

Same error on Windows/Linux/OS X.

All of the required files seem to be in the resulting jar.

Any suggestions as to what I am missing would be appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Move to native jar: nearly there, but not quite

gouessej
Administrator
Hi

Sorry to repeat that once again but packaging a whole application as a single JAR is a very bad idea, it's dirty and it will obviously not work on a lot of machines because other applications may try to open the JAR instead of allowing the user to run your program, for example Arch under GNU Linux and WinRAR under Windows. Rather use Java Web Start with several JARs, don't put everything into the same JAR. If you need an example, look at the Ant script used in my game.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Move to native jar: nearly there, but not quite

Sven Gothel
Administrator
In reply to this post by LordSmoke
I agree w/ Julien here.

However, if you really must deploy your app as one JAR file,
you may like to chose the jar-in-jar solution as described
in Bug 522 / Comment 7 / Test 2:
  <https://jogamp.org/bugzilla/show_bug.cgi?id=522#c7>

Yes, it's Eclipse related, i.e. the JAR-IN-JAR is produced by Eclipse
and I haven't test the creation with a vanilla JDK/Ant or NB.
However, as long the JogAmp JAR file names and content
are 'somewhat' preserved .. you can encapsulate them as shown.
Reply | Threaded
Open this post in threaded view
|

Re: Move to native jar: nearly there, but not quite

LordSmoke
In reply to this post by LordSmoke
Thanks for the speedy feedback. I am not a Web developer, so the Web start stuff looks like classic Greek to me. However, I think I have found a solution. I exclude the platform-specific jars from the application jar package and just include them with the app in a .zip file. It is not unreasonable for me to have my users unzip that file into the application directory. That seems to work fine on OS X, Windows, and Linux. They can delete the unneeded ones if they wish.

Now, to look at Java3D, again. :)

Again, thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Move to native jar: nearly there, but not quite

gouessej
Administrator
Java Web Start is not difficult to use and you can use another installer if you prefer, it would be more user friendly than a zip. If you want to get more feedbacks, you should do your best to ease the install process.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Move to native jar: nearly there, but not quite

LordSmoke
gouessej wrote
Java Web Start is not difficult to use and you can use another installer if you prefer, it would be more user friendly than a zip. If you want to get more feedbacks, you should do your best to ease the install process.
With this prodding, I looked around and found PackJacket and IzPack. The former is an older ('09) graphical front-end to the current latter. I now have three platform-specific installers, and the user can download the one they want - dbl-click and go. Only complexity is setting the exec flag on Linux, but if they are using Linux, that should not be too bad. Also, the result does not do well overwriting earlier installations of the software and failed to create a windows-executable .exe. All good enough for now. Will look into WebStart (or have students do that) later.

-LS
Reply | Threaded
Open this post in threaded view
|

Re: Move to native jar: nearly there, but not quite

gouessej
Administrator
IzPack is nice, very complete but there is no auto update feature and it is harder to use than Java Web Start. Sorry to contradict you but lots of laptops and netbooks are sold with Ubuntu, some people using GNU Linux are not technical people. Java Web Start allows to have a simple installer that works where Java itself is installed and it can even trigger the install of a more recent JVM if you want. You can read this tutorial to learn how to use it:
http://docs.oracle.com/javase/tutorial/deployment/webstart/
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Move to native jar: nearly there, but not quite

LordSmoke
gouessej wrote
IzPack is nice, very complete but there is no auto update feature and it is harder to use than Java Web Start. Sorry to contradict you but lots of laptops and netbooks are sold with Ubuntu, some people using GNU Linux are not technical people. Java Web Start allows to have a simple installer that works where Java itself is installed and it can even trigger the install of a more recent JVM if you want. You can read this tutorial to learn how to use it:
http://docs.oracle.com/javase/tutorial/deployment/webstart/
My users are almost entirely life-sciences folks that tend to be math/computer averse (but that makes me look good :) ). I would estimate 80-90% only use Windows machines, ~10% (but growing) go with Macs (popular in genetics), and the remaining few Linux users are real or wannabe techies. I have asked for a volunteer amongst my (quite talented) minions to look into web start and general web development. Thanks for the link.
Reply | Threaded
Open this post in threaded view
|

Re: Move to native jar: nearly there, but not quite

gouessej
Administrator
I hope you will tell us more about your application :) I'm curious. If you choose not to host JOGL and GlueGen JARs on your own server, you will need only a very small JNLP file of about less than 20 lines. Good luck.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Move to native jar: nearly there, but not quite

LordSmoke
gouessej wrote
I hope you will tell us more about your application :) I'm curious. If you choose not to host JOGL and GlueGen JARs on your own server, you will need only a very small JNLP file of about less than 20 lines. Good luck.
I will do that separately. I just use a pseudonym for my technical inquires and personal stuff so searches for my name only turn up professional sites and postings. And, I am a agent for a super secret international organization seeking world domination!