Question

I have a class that uses Java3D that successfully compiles, although when I try to run it it says: Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/j3d/Canvas3D,

With the following stack trace:

        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.media.j3d.Canvas3D
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)

Stuff I have already tried:

  1. I couldn't even get it to compile until I copied the Java3D jars into /jre/lib/ext/.

  2. I have the latest Java, Java3D and I am using Notepad++ and I have tried reinstalling Java3D.

  3. I have set the classpath/path correctly.

  4. There are no errors in the code.

  5. I can run normal Java applications I have created.

  6. I have tried using the classpath thing when running the application (java -classpath blahblah ApplicationName).

  7. I have checked inside the jars and the classes (including Canvas3D) are definitely in there.

Was it helpful?

Solution

Not everything you say is true.

IF the classes are in the jars, and IF you have set the classpath correctly, THEN you would not get this message.

I suspect you have a build path confused with a classpath (which is mostly associated with runtime, where build path is associated with compile time). Without knowing more details of your runtime environment, it's hard to be more specific.

It always puzzles me how someone with a problem they cannot solve asserts so definitely that all these things are set up "correctly": how do you know? Isn't the problem some evidence to the contrary, at least enough for a small doubt?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top