Why am I getting ClassNotFoundExpection when I have properly imported said class and am looking at it in its directory?
Posted
by
Strider
on Stack Overflow
See other posts from Stack Overflow
or by Strider
Published on 2012-05-31T04:27:42Z
Indexed on
2012/05/31
4:41 UTC
Read the original article
Hit count: 182
This is my Javac compiling statement:
javac -cp "C:\java\code\j3D\j3dcore.jar;C:\java\code\j3D\j3dutils.jar;C:\java\code\j3D\vecmath.jar" Simple.java
- compiles with no problems.
The three jar files (j3dcore, j3dutils, and vecmath) are the essential jar's for my program (or at least I am led to believe according to this official tutorial on J3D
For the record I ripped this code almost line from line from this pdf file.
- jar files are correctly located in referenced locations
When I run my Simple program, (java Simple) I am greeted with
Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/j3d/Cavas3d Caused by: java.lang.ClassNotFoundExpection: javax.media.j3d.Canvas3D
Currently I am staring directly at this Canvas3D.class that is located within j3dcore.jar\javax\media\j3d\
wtfisthis.jpg
Here is the source code:
//First java3D Program
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.awt.GraphicsConfiguration;
public class Simple extends Applet {
public Simple() {
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config);
add("Center", canvas3D);
BranchGroup scene = createSceneGraph();
scene.compile();
// SimpleUniverse is a Convenience Utility class
SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
// This moves the ViewPlatform back a bit so the
// objects in the scene can be viewed.
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(scene);
} // end of HelloJava3Da (constructor)
public BranchGroup createSceneGraph() {
// Create the root of the branch graph
BranchGroup objRoot = new BranchGroup();
// Create a simple shape leaf node, add it to the scene graph.
// ColorCube is a Convenience Utility class
objRoot.addChild(new ColorCube(0.4));
return objRoot;
}
public static void main(String args[]){
Simple world = new Simple();
}
}`
- Did I import correctly?
- Did I incorrectly reference my jar files in my Javac statement?
- If I clearly see Canvas3D within its correct directory why cant java find it?
- The first folder in both j3dcore.jar and vecmath.jar is "javax". Is the compiler getting confused?
- If the compiler is getting confused how do I specify where to find that exact class when referencing it within my source code?
© Stack Overflow or respective owner