Creating an executable .jar file

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

Creating an executable .jar file

AlexRNL
Hi everyone!

I'm currently working on a JOGL (1.1) app and i want to make a jar file so it can be deployed on other computers easily.

Unfortunately, it's not working.

I'm using the "export tool" in eclipse but as soon as i want to launch my jar (from the command line, with java -jar myJar.jar) i'm getting a very mysterious output :

Exception in thread "main" java.lang.NoSuchMethodError: javax.media.opengl.GLDrawableFactory.getFactory()Ljavax/media/opengl/GLDrawableFactory;
        at javax.media.opengl.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java
:520)
        at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:131)
        at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:90)
        at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:83)
        at sytar.sample.SwingRTLauncher.main(SwingRTLauncher.java:69)

It seems that my libs are not correctly copied by eclipse into the jar... but when I decompile the javax.media.opengl.GLDrawableFactory.class file in the jar, the function was available!!

Now, I've tried using the -Djava.library.path=mypath but it wasn't working either...

And the strangest thing is when I tried that with a JOGL 2.0 project, it was working very well... but unfortunately, I'm required to use JOGL 1.1 for that project...

Thanks in advance for any clue that'll help solve my problem :)
Alex.
Reply | Threaded
Open this post in threaded view
|

Re: Creating an executable .jar file

Wade Walker
Administrator
Hi Alex,

If your app is an Eclipse RCP app, you could try the instructions in my tutorial at http://wadeawalker.wordpress.com/2010/10/24/tutorial-creating-native-binary-executables-for-multi-platform-java-apps-with-opengl-and-eclipse-rcp/. I've used this same procedure with JOGL 2 and JOGL 1.1.1a, and it works fine for both.

If your app is not an RCP app, you'd need to manually do some of what the Eclipse framework does for you -- it unpacks the JOGL JARs at runtime so the .dll/.so files are visible in the app's classpath. My tutorial discusses this a bit at the beginning, and I also mention some of the other possible tools that do this, like launch4j and JSmooth.
Reply | Threaded
Open this post in threaded view
|

Re: Creating an executable .jar file

Worker
In reply to this post by AlexRNL
Make it simpler.
Take the program power archiver from the net.
Open it, and chosse new archieve.
After you have choosen a name e.g. myApp.jar, click save and
then you can automatically drop into the jar what you want.
If you a ready, click 'close archiv' and you has alll what you need.

Or take 'ant' in eclipse for that.

Eclipse make's good war's or ear's, but not jars.

 
Reply | Threaded
Open this post in threaded view
|

Re: Creating an executable .jar file

Wade Walker
Administrator
Worker wrote
Make it simpler.
Take the program power archiver from the net.
PowerArchiver doesn't help with the original poster's question. Creating the JAR is the easy part -- you can do that with many different programs. Even the "jar" program that ships with Java works fine for this

The problem comes when you try to run a JOGL program from a JAR. You have to pull the JOGL DLL/SO files out of the JAR at runtime, then copy them to a directory on the filesystem that's on the java.library.path. If you don't do this, the loadLibrary() calls in JOGL won't work, and your program won't run.

SWT solves this problem by unpacking its own DLL/SO files the first time you call into the SWT library. JOGL requires that some outside code (either Eclipse RCP, some custom code of your own, or some other framework like Java Web Start) has unpacked the DLL/SO files, so JOGL just calls loadLibrary() and assumes it will work.
Reply | Threaded
Open this post in threaded view
|

Re: Creating an executable .jar file

gouessej
Administrator
In reply to this post by AlexRNL
Hi!

Look at my deployment system based on ANT and that can be used in Eclipse. I use it to deploy my first person shooter that still relies on JOGL 1.1.1a and Java Web Start. Good luck.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Creating an executable .jar file

Worker
In reply to this post by Wade Walker
Ah , i see what you mean.
Yes in this case the library path is needed, and the main class
and class path's must be in the MANIFEST.MF in think.
Reply | Threaded
Open this post in threaded view
|

Re: Creating an executable .jar file

AlexRNL
In reply to this post by AlexRNL
Thanks everyone for your replies!

I manage to make it work using a .bat file and specified specific directories for my libs and my jars, it seemed that I had some of these libs in the jvm base directory so it was only working with JOGL 2.

But now it's fine, I will check it on another computer when i can but it should be working (as long as the drivers are up to date ^^).

Thanks again :)