This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes J3D NoClassDefFound Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "J3D NoClassDefFound" Watch "J3D NoClassDefFound" New topic
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
Sheriff

Joined: Oct 01, 2001
Posts: 2833
    
  11

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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: J3D NoClassDefFound
 
Similar Threads
Java3D previously working, reinstalled and now not working...set classpath and path
Eclipse and Java 3D problem
Java 3D Classpath
windows user name
j3dcore-ogl.dll: Can't find dependent libraries