Java Help

I need help…

I have Java 3D and Docs installed
JDK and docs installed
JVM installed

In Sun’s tutorial on getting HelloJava3Da working I run into these problems…

Step 1: I put this into a text editor:

[i]public class HelloJava3Da extends Applet {
public HelloJava3Da() {
setLayout(new BorderLayout());
Canvas3D canvas3D = new Canvas3D(null);
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;
} // end of createSceneGraph method of HelloJava3Da
} // end of class 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)

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.
;[/i]

  • then i attempt to Javac it, and it does javac it successfully… BUT

Step 2: Upon it Javac’n i get 10 errors and they are:

http://img223.imageshack.us/img223/2438/37692686pf2.jpg

I have all the latest docs ‘downloaded’ but I guess I apparently didn’t put them in the right directory… I mean I did download them and put them in (for example) J3D docs I put w/ java 3d…

NEED ONE HUGE FAVOR - Can someone please recommend a book to start with to learn java programming that will secure me for learning how to program in java 3d - A good book please - thanks

Anyways yea

How to ask questions the smart way

Nice try but learn how to read that obviously doesn’t answer my question

and you obviously didn’t read the link ::slight_smile:

You might not have noticed, but you pressed capslock.

How on Earth would you expect any meaningful answer to your post.

If you’re really that frustrated over coding, maybe you should pick another hobby or job.
You know the nice thing about such problems in programming? It’s always your fault!
Realizing that, you know that there is a solution, and it just needs some clear thinking.
Ofcourse, I get frustrated too, every once in a while, but it hardly ever occured that it was
Sun who was to blame. It was always me screwing up. So either sit down and ponder
a bit about the problem, trying to figure it out. If that doesn’t help, try to tell others exactly
what you did to solve the problem, and where you got stuck. If you simply tell everybody
it just won’t work, we can’t do much but agree.

So… now what exactly was the problem?

This is my problem:

I managed to fix the javac problem but this is my other one…

The first tutorial that Sun offers on how to open up the Universe App and what not… Every time I enter the code in I always get an error, it compiles but it never works it’s so irritating. There is always (now) one error that wont work. Before it would never compile but it does now… Thankfully…

Actually you need to post the exact error messages whenever you ask someone in a forum for help.

I updated first post with problem…

  1. “import” statements go right at the top of source files (but underneath “package” statements, but you don’t have any of those).

  2. All methods need to reside within a class. Your main() method is outside a class and needs to be moved within the HelloJava3Da class.

I do have those I downloaded them off of sun… Can you show me a pic of where they go?


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.*;

public class HelloJava3Da extends Applet
{

    public HelloJava3Da()
    {
        setLayout(new BorderLayout());
        Canvas3D canvas3D = new Canvas3D(null);
        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;
    } // 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

Too much ads on this page, but it seems to explain the basics: http://java.about.com/od/beginningjava/a/beginjavatutor.htm

Thanks any recommended must read books?

Cylab I did what you said in your script and now i have 15 errors… lol

I haven’t testet it, since I have not J3D installed. Sorry… paste the error-messages… make it a habbit, when asking for help :stuck_out_tongue:

You don’t have to make a screenshot. Right click on the command prompt icon in the comand prompt’s title bar, open properties, check the quick edit mode, close the dialog with OK. Check to apply the properties to all windows (it’s the second option… don’t know the exact words, no english windows). After that you can select regions in the command window with your mouse and copy the selected text to the clipboard by right click.

Just installed Java3D and tried the code… There was an error in it (maybe from your tutorial)


        Canvas3D canvas3D = new Canvas3D(null);

has to be:


        Canvas3D canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());

other than that, the code compiles and runs fine.