File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "J3D NoClassDefFound" Watch "J3D NoClassDefFound" New topic

J3D NoClassDefFound

Ben Burt

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

Joined: Oct 01, 2001
Posts: 2961

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: 15033

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 8 API documentation
I agree. Here's the link:
subject: J3D NoClassDefFound
It's not a secret anymore!