| Author |
J3D NoClassDefFound
|
Ben Burt
Greenhorn
Joined: Jun 28, 2010
Posts: 3
|
|
Hi all this is my first post and I apologise if it is the wrong section. The title *sort of* says it all. I have googled my error but not been able to find any solutions and many results pointed to coderanch so I guess this is a good place .
I have the two files attached which will run up to the pop up of 4 on it's own.
The meh is the main class and it loads the DLLs via system.load and it also copies them if they don't exist (Although on my test machine I have downloaded the correct dlls from the j3d site as the ones I have packaged don't work at all.) That causes no problems.
The problem comes in the dr class. This class tries to display a simple universe but when I run the with "java -jar C:\test.jar" I get NoClassDefFound javax/media/j3d/Node. I don't understand it as I have set both the java.class and java.library paths to include where the files are copied to (Verified by JOptionPane.showMessageDialogs). I also try to load them through
Class DR
Class meh
Thank you in advance for any help you can give.
|
 |
Greg Charles
Bartender
Joined: Oct 01, 2001
Posts: 2542
|
|
Hi Ben,
Welcome to Java Ranch! You heard right, it is a good place.
Classpath issues are common in Java, and can be quite confusing. However, the solution is rarely to write your own class loader. What you want is to provide a complete class path to the java executable. Something like:
java -cp mylibdir/j2dutils.jar;mylibdir/vecmath.jar;mylibdir/j3dcore.jar;myclassesdir my.main.RunClass
Each entry on the classpath should be either a directory that contains class files (in a folder tree replicating the package structure) or a jar file. You can set an environment variable CLASSPATH instead if you want
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
Beware that when you run your program with java -jar, you cannot specify the classpath with -cp or -classpath - it will simply be ignored when you use the -jar option. Also the CLASSPATH environment variable will be ignored when you run your program with the -jar option.
Instead, you'll have to specify the classpath in the manifest file of your JAR: Adding Classes to the JAR File's Classpath
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: J3D NoClassDefFound
|
|
|