e-mail from Bertil Gralvik

From: "Bertil Gralvik"
To: Martin Baker
Subject: Troubleshooting page on martinb
Date: 26 November 2002 23:35

Hello Martin!

As I'm always more interested in 3D/WRML than I'm ever allowed time for, I use to scan the world for good tools in the area - preferrably free of
charge :)
First I'll be sure to congratulate you to an amazing job ( though I haven't
been able to run your code yet).
Also I really like your easily navigated web site - I'll be sure to mimic
that for my course webs.
There are a few confusing comments on your truobleshooting page for the
mjbWorld - Java version.

Here is what I found on Windows XP: ( Sorry - it tends to be a lenghty story )

I really got the ZIP-exeception as mentionen by one user.

The suggestion was that the jar-file might have been corrupted during
transport.
I don't belive this to be the best guess as it is encapsulated in a
ZIP-file which is readily unarchived.
First a bit of backgruond to my findings:

Under Windows you don't have to set the CLASSPATH environment variable at all and certainly not excessively as in your bat-files. Rather this should be avoided.

After the JDK is installed ( >1.2 ) the system uses the PATH varailble and
the javac and java programs finds all
libraries including extensions as j3dcore.jar, j3dutils.jar etc.

Installing j3d from sun in the same directory as the JDK ( Java2jsdk_xxx )
ensures that we only have to set CLASSPATH to point to libraries residing
in other directories ( third party and our own ).
If the CLASSPATH variable is set for one of this reasons we have to include
./; i.e. "current directory".

So I checked to see that the CLASSPATH was *not* set.
---------------------------------------------------------------------------------------------------------------------------
Now to the experiments: ( All from the command prompt )

1. Checking the Java installation

C:\>java -version
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

Seems Ok!

2. First try at running the mjbWorld from the install directory

D:\JAVA\mjbWorld>java mjbWorld.mjbWorld

Exception in thread "main" java.lang.NoClassDefFoundError:
mjbWorld/mjbWorld

This is far too simple of course. There is no directory mjbWorld (
exept inside the jar archive )

3. Trying to run the program telling the java luncher to look in the archive

D:\JAVA\mjbWorld>java -jar mjbWorld mjbWorld

Exception in thread "main" java.util.zip.ZipException: The system
cannot find the file specified
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:112)
at java.util.jar.JarFile.<init>(JarFile.java:117)
at java.util.jar.JarFile.<init>(JarFile.java:55)

Here the ZipException is reproduced
due to my faulty statement that the name of the archive is mjbWorld.
It has to be fully qualified - including the jar extension.

4. OK. So I'm giving the qualified name to the launcher

D:\JAVA\mjbWorld>java -jar mjbWorld.jar mjbWorld
Failed to load Main-Class manifest attribute from
mjbWorld.jar

Here we can see that there is nothing corrupt about the archive.
No complaints to that effect, but the launcer expects to get some
hints
from the manifest on the main class.

5. Qualifying the mjbWorld class with the package name ( of course ;)
D:\JAVA\mjbWorld>java -jar mjbWorld.jar mjbWorld.mjbWorld
Failed to load Main-Class manifest attribute from
mjbWorld.jar

The launcer still wants a hint from the mainfest ( Which is not
there )

6. The best we can do is to add the advise on the start class to the mainfest
It can be done using the jar tool, but I choosed to use WinZip
1. Extract the archive using WinZip keeping the directory structure
2. Open the MANIFEST.MF file in a texteditor and
3. Add the line
Main-Class: mjbWorld/mjbWorld
4. Make sure to have an extra empty line
5. Archive all directories with WinZip and rename the file
mjbWorld.jar

Now it is all very simple to run:
With J3D installed to the same directory as the JDK
making sure CLASSPATH is not set we may now give the command

java -jar mjbWorld.jar

and the Java launcher will take care of all dependencies

If you don't like the Command Prompt and rather duoble click from Windows
Explorer,
you just create a Commandfile, e.g "mjbWorld.bat" containing the same
command line
and click away on that.

To the best of my knowledge ( as is clause :)
/Bertil


metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

 

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2017 Martin John Baker - All rights reserved - privacy policy.