I’m running some 3d example code from oracle in Eclipse, but I get many errors saying ‘rename in file’. Does someone know why there are so many errors?
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.*;
import java.awt.GraphicsConfiguration;
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.*;
//HelloJava3Da renders a single, rotating cube.
public class HelloJava3Da extends Applet
{
public HelloJava3Da()
{
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config);
add("Center", canvas3D);
BranchGroup scene = createSceneGraph();
// SimpleUniverse is a Convenience Utility class
SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
// This will move 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();
objRoot.addChild(new ColorCube(0.4));
return objRoot;
} // end of CreateSceneGraph method of HelloJava3Da
// The following allows this to be run as an application
// as well as an applet
public static void main(String[] args)
{
Frame frame = new MainFrame(new HelloJava3Da(), 256, 256);
} // end of main (method of HelloJava3Da)
} // end of class HelloJava3Da
looks to me that you are missing some libraries. use for example this to find the jars you are looking for. that link contains the jar for vecmath. after that, depending on the IDE you use, you must download the missing jars and add them to the classpath.
you will need to find the corresponding JARs for the following lines of code:
findjar.com is a great spot to search for missing JAR files.