Help loading Xith and other libraries on Windows

I’m trying to send this application written using Xith to my PC friends who don’t have Xith or anything else installed (besides Java of course).

To make it easy for them to launch it, I made a ‘run.bat’ file that they can use to load the libraries and launch the app:

java -Djava.library.path=libs\ -Djava.ext.dirs=libs\ -cp libs\;libs\jogl-natives-win32.jar;libs\jogl.jar;libs\vecmath.jar;libs\xith3d.jar -jar Mouse.jar

Now, in the ‘libs’ folder are the following items:

jogl-natives-win32.jar 
jogl.dll 
jogl.jar 
jogl_cg.dll 
vecmath.jar 
xith3d.jar 

I’m on a Mac so I have difficulty figuring out what exactly is the problem.

When they run the command they get the following error:

Exception in thread "main" net.java.games.jogl.GLException: java.lange.ClassNotFoundException: net.java.games.jogl.impl.windows.WindowsGLContextFactory
       at net.java.games.jogl.impl.GLContextFactory.getFactory<GLContextFactory.java: 78>
      at net.java.games.jogl.GLDrawableFactory.createGLCanvas<GLDrawableFactory.java:150>    
      at net.java.games........ blah blah

I think I’m missing a library or something. How do I get it to run?

You’re doing this all wrong.

Start again, using webstart.

It will be quicker, easier, and much easier for them to run!

Webstart, on a good day, takes only 30 seconds for you to setup, and is built in to the JVM so they don’t need to do anything - one click and it runs.

On a bad day, it could take you half an hour to notice the typo you made that is making it not work :(.

There’s a brief intro/tutorial on JGF (link in my sig below, go to the articles section). There’s a lot of xith3d specific info on webstart in these forums.

Um… ok. I’ll try that, but I would also like to figure how to do it this way too. Most large applications written in Java don’t use Webstart and simply include folders with all the libraries (I tried including the libraries in a single Jar file using the manifest file and the Class-Path header but that didn’t work either).

When my project is finished, it will have a very large amount of files and libraries that I’ll need to distribute to a lot of people and I don’t think WebStart would be the way to go for that. For example, to reduce bandwidth I might want to distribute it using Bittorrent.

The Xith3D-specific JWS tutorial is here: http://xith.org/tutes/GettingStarted/html/deploying_xith3d_games_with.html

I agree with blar*3, it’s the far better choice if you can.

The error message looks like jog.jar is missing.

Ah-ha! You can’t use the -jar command with the -cp command! .jar’s have their own Class-Path defined in the meta-inf/manifest.mf file. Really there is little use in using executable jar’s unless all your classes are in the one jar in my opinion (you can get it to work with multiple-jars but you lose some of the benifits). Reference “Mouse.jar” in the -cp, and call the full class name (e.g. com.blar.Mouse).

avoid using -jar for applications of this type (save it for more self-contained ones).

Will.

I posted that before reading your reply. Don’t forget that conceptually the native libraries are very different to the java ones (just because they are in .jar files doesn’t change anything). They are treated differently (i.e. go in the library.path rather than the class path). “jogl-natives-win32.jar” shouldn’t be in your -cp . In fact I’m not sure why your native DLL’s are in a .jar files (I thought most people only did that for JWS).

I again (see other thread) recommend using the Xith3d demo .bat files as your guide.

Will.

[quote]I posted that before reading your reply. Don’t forget that conceptually the native libraries are very different to the java ones (just because they are in .jar files doesn’t change anything). They are treated differently (i.e. go in the library.path rather than the class path). “jogl-natives-win32.jar” shouldn’t be in your -cp . In fact I’m not sure why your native DLL’s are in a .jar files (I thought most people only did that for JWS).

I again (see other thread) recommend using the Xith3d demo .bat files as your guide.

Will.
[/quote]
Ok, I just had it there just to make sure… The DLL’s aren’t in .jar files, they’re just in the libs folder. Thanks for the suggestion though, I’ll try doing as you suggested in your previous post (didn’t know -cp can’t be used with -jar). Thanks again.

[quote]Um… ok. I’ll try that, but I would also like to figure how to do it this way too. Most large applications written in Java don’t use Webstart and simply include folders with all the libraries (I tried including the libraries in a single Jar file using the manifest file and the Class-Path header but that didn’t work either).
[/quote]
Most games aren’t written in java. But that’s not a reason in and of itself not to do so yourself.

There is a thread around here somewhere (perhaps in tools? or offtopic?) about the fact that webstart is perfect for games - and, I suspect, for what you are doing - but a poor choice for e.g. MS office (if office were written in java).

Almost all good games today are packaged using webstart. Maybe your application isn’t a game, and isn’t a good fit for it, but I would check it out first and at least understand WHY it’s so good for games before rejecting it.

No-one does until it bites them >:(. I think I once got sufficiently aggravated by this on one occasion that I filed a bug-report to Sun claiming it was a bug not a feature :). I certainly have filed a couple about command-line switches to java and javac - some are broken (in particular situations), others have the wrong name for what they do IMHO :(.

OK. I’m not rejecting it though, I plan on figuring it out later and using it, but I’d also like to get it working this way so that I have the option of choosing which-ever turns out best :slight_smile:

You know… I’m beginning to think Mr. Blah is right… It just refuses to work. I’m sending them the simple MouseInteraction demo that’s included with the xith examples, and now using this command:

java -Djava.library.path=libs\ -Djava.ext.dirs=libs\ -cp libs\;libs\jogl.jar;libs\vecmath.jar;libs\xith3d.jar;Mouse.jar MouseInteraction

And it’s still giving them the same error… which is a real pity… I’d really like to get this working, but it seems like in the mean-time i’ll have to use JWS… :frowning:

Edit: it really looks like some library (native or not) having to do with JOGL is not being included… am I missing something?

Edit: btw, i commented out the package in the source so that’s why it’s simply MouseInteraction

The Xith3D demos work out of the box on a clean windows machine.

Using the MouseInteraction instead of the com.xith3d.test.CubeTest demo is a matter of adding one extra .jar to the jar path and changing the class that is executed.

Have you looked at the “runtest.bat” and other “.bat” files in the xith3d/demo folder as I suggested?

Will.

Yeah, I did, kinda… taking a look again I noticed a few small differences. My friends are offline right now (as it’s 2 AM) so I can’t test it now, and I’m tired myself so I’ll try again tomorrow, following the runtest.bat file more closely and reply here with the results.

Sorry to continue off topic, but it particularly irritated me when I was trying to jar my files up and it said Class-Path line was too long!! I had to shorten up all the paths just to be able to use all the jars! :stuck_out_tongue:

well… i copied the runtest.bat file almost exactly:

set PATH=%PATH%;libs\
java -Djava.library.path=libs\ -Djava.ext.dirs=libs\ -classpath libs\;libs\jogl.jar;libs\vecmath.jar;libs\xith_utilities.jar;libs\junit.jar;libs\log4j.jar;libs\xith3d.jar;Mouse.jar MouseInteraction

And it didn’t work, I dunno what is the problem, i even tried changing the backslashes into forward slashes the way the runtest.bat file has them and it still didn’t work. Perhaps my friend messed up somewhere. I’ll continue trying… and if I ever get it to work I’ll post again… I know I’m missing something… if I had a PC to do it myself on it’d be much easier.

why is this in your command “-Djava.ext.dirs=libs” as far as I know it should work without it…

It’s very hard when you don’t have a test machine. I felt that way about Mac’s when I didn’t own one. Fortunately I know have access to OS X, Windows and Linux. Debugging takes days instead of minutes.

Will.

[quote]why is this in your command “-Djava.ext.dirs=libs” as far as I know it should work without it…

It’s very hard when you don’t have a test machine. I felt that way about Mac’s when I didn’t own one. Fortunately I know have access to OS X, Windows and Linux. Debugging takes days instead of minutes.

Will.
[/quote]
I think you mean debugging takes minutes instead of days :wink:

Actually, I’ve changed the command again to be:

java -Djava.library.path=libs\natives -Djava.ext.dirs=libs -cp .;libs\;libs\jogl.jar;libs\vecmath.jar;libs\xith3d.jar;Mouse.jar MouseInteraction

This has a slightly different setup, where the native files “jogl.dll” and “jogl_cg.dll” are in a folder called “natives” in the folder “libs”. “libs” still contains vecmath.jar, xith3d.jar, and jogl.jar. With this new command I’m getting a different error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/xith3d/scenegraph/Node (Unsupported major.minor version 48.0)
       at java.lang.ClassLoader.defineClass0(Native Method)
       at java.lang.ClassLoader.defineClass(Unknown Source)
blah blah...

I’m not sure what it means, can anyone make anything of it?

heh, this one is easy - tell them to get Java 1.4.2 :slight_smile:

They are probably running 1.3

Will.

[quote]heh, this one is easy - tell them to get Java 1.4.2 :slight_smile:
[/quote]
OR, if you’d used webstart, it would just have worked automatically!

K. I’ve gotten it working with JWS–on a mac. Windows gives me the same exception the command line has been giving me for eons:

net.java.games.jogl.GLException: java.lang.ClassNotFoundException:
net.java.games.jogl.impl.windows.WindowsGLContextFactory
      at net.java.games.jogl.impl.GLContextFactory.getFactory(GLContextFactory.java:78)
      at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:150)
      at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:118)
      at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:104)
... blah

I’ve developed a new hatred for Windows during this ordeal… though I know it’s my fault, i’m doing something wrong. If anyone wants to take a closer look, the jnlp file is here (my host doesn’t support the mime format…):
http://www.kinostudios.com/jws/MouseInteraction.jnlp
All the files I’m using are here:
http://www.kinostudios.com/jws/

The main class is in Mouse.jar in the jws directory.

I hope you guys can figure out what I’m doing wrong. I think it has something to do with the jogl.jar file–not the natives files, but I can’t confirm that. edit: scratch the vacation bit, they’ve got Cable internet here!

The exception ClassNotFoundException means that Java can not find the given class in your classpath. In this case, the class in question is " net.java.games.jogl.impl.windows.WindowsGLContextFactory".

Have you checked your classpath for this class? I’m guessing you havn’t so I’ll have a look myself. I will make the assumption that you have assumed this class, being related to JOGL is in the jogl.jar file.

Lets take a look at that file:


$ wget http://www.kinostudios.com/jws/libs/jogl.jar
$ unzip -l jogl.jar | grep WindowsGLContextFactory

Interesting - there was no output from grep - so jogl.jar doesn’t have this class file. I won’t look at the other .jar’s in your class path as I am pretty sure you are expecting jogl.jar to have this class.

Can you “normally” expect jog.jar to have this file? Lets compare the
output from a known “good” jogl.jar file (this one straight from Xith3D CVS).


$ unzip -l ~/proj/xith3d/third-party/jogl/jogl.jar | grep WindowsGLContextFactory
     2278  04-29-04 14:58   net/java/games/jogl/impl/windows/WindowsGLContextFactory$1.class
      771  04-29-04 14:58   net/java/games/jogl/impl/windows/WindowsGLContextFactory$2.class
     3504  04-29-04 14:58   net/java/games/jogl/impl/windows/WindowsGLContextFactory.class

It appears that jogl.jar usually has this class file, but the version you are using isn’t the one from Xith3D CVS and doesn’t have this file.

Will.