File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

J3D NoClassDefFound

 
Ben Burt
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic