How to bundle libraries with app?

I’m relatively new to Java, and have just finished learning its basics and how to make GUI’s using swing. I am now ready to move on to learning Xith3D. First I’d like to know how to bundle the Xith3D libraries with an app so that the user doesn’t have to install them into their Java Library directories manually. I tried making a jar file by simply including the application classes, and the libraries and putting them all in one Jar, but it still refuses to launch, even though the libraries are in the same directory as the class files.

So how do I bundle them to make it easy for users to open the app on their computers? ???

how about using JWS?

Otherwise - you can bundle all the resources into a big .jar file - and have the native code seperately then use a shell script to launch it all. Check out the .bat files in the Xith3D distribution - you can run them without having Xith3d “installed” at all.

Will.

[quote]how about using JWS?

Otherwise - you can bundle all the resources into a big .jar file - and have the native code seperately then use a shell script to launch it all. Check out the .bat files in the Xith3D distribution - you can run them without having Xith3d “installed” at all.

Will.
[/quote]
On OS X I tried to put the classes and libraries all in one folder, and do: ‘java -Djava.library.path=./ -classpath xith3d.jar:jogl.jar:etc:etc MyClass’ but it still wouldn’t launch, complaining about an exception or something in the thread ‘main’. What exactly is the command that would launch the class if the class and libraries are all in one folder?

Edit: the exact message is:

Exception in thread "main" java.lang.NoClassDefFoundError: MouseInteraction

after typing in:

java -Djava.library.path=./ -classpath jogl.jar:jogl-natives-macosx.jar:vecmath.jar:libjogl.jnilib:xith3d.jar:xith_utilities.jar:vorbis.jar:log4j.jar:junit.jar MouseInteraction

As far as I know, this should work on a fresh OS X system, with Xith3D downloaded


java -Xms128M -Xmx256M -Djava.library.path=third-party/jogl/macos/:third-party/joal/macosx/ -cp classes:./:third-party/vecmath/vecmath.jar:third-party/jogl/jogl.jar:third-party/misc/log4j.jar com.xith3d.test.CubeTest

You’re getting your native library and java library stuff mixed up. Native libraries arn’t normally in .jar files - that is for JWS so they can be signed. Native libraries are never declared on the -classpath - but in the -Djava.library.path

Nice thing about Mac OS X, 10.3 is of course that Java is pre-installed (with JWS). This together with the fact Mac’s have quite good graphics cards normally (the OS uses OpenGL in the GUI’s after all), you have quite a good target platform.

Will.

[quote]As far as I know, this should work on a fresh OS X system, with Xith3D downloaded


java -Xms128M -Xmx256M -Djava.library.path=third-party/jogl/macos/:third-party/joal/macosx/ -cp classes:./:third-party/vecmath/vecmath.jar:third-party/jogl/jogl.jar:third-party/misc/log4j.jar com.xith3d.test.CubeTest

You’re getting your native library and java library stuff mixed up. Native libraries arn’t normally in .jar files - that is for JWS so they can be signed. Native libraries are never declared on the -classpath - but in the -Djava.library.path

Nice thing about Mac OS X, 10.3 is of course that Java is pre-installed (with JWS). This together with the fact Mac’s have quite good graphics cards normally (the OS uses OpenGL in the GUI’s after all), you have quite a good target platform.

Will.
[/quote]
Thanks! I don’t really know what I was doing wrong (I think it might have been forgetting including the current directory), but using yours as a model, I got it to load the class with all the libraries in its directory:

java -Djava.library.path=. -cp .:jogl-natives-macosx.jar:jogl.jar:vecmath.jar:xith3d.jar:xith_utilities.jar MouseInteraction

Thanks again!