Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (683)
Games in Android Showcase (196)
games submitted by our members
Games in WIP (750)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Trouble with suns Java 3d tutorial (solved)  (Read 1857 times)
0 Members and 1 Guest are viewing this topic.
Offline Rabe

Junior Newbie

« Posted 2007-08-23 17:27:15 »

Hallo, i tried to learn something about java 3d by following sun's java 3d tutorial step by step but everytime i try to compile i get a NullPointerException. The code from the Example is listed below, I'm working with the Eclipse IDE on a Windows system (which shouldn't matter anyway, because it should work on any IDE / OS, but I listed those things just in case...)


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

public class HelloJava3Da extends Applet
   public HelloJava3Da()
      setLayout(new BorderLayout());
      Canvas3D canvas3D = new Canvas3D(null);
      add("Center", canvas3D);

      BranchGroup scene = createSceneGraph();

    // 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.

   } // 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)

Offline InteractiveMesh

Senior Newbie

« Reply #1 - Posted 2007-08-24 08:43:55 »


a null GraphicsConfiguration throws a NullPointerException in the current Java 3D 1.5.x release. Give this a try:

import java.awt.GraphicsConfiguration;
GraphicsConfiguration gc = SimpleUniverse.getPreferredConfiguration();

Canvas3D canvas3D = null;
try {
    canvas3D = new Canvas3D(gc);
catch (NullPointerException e) {
    // handle exception
catch (IllegalArgumentException e) {
    // handle exception

Good luck, August
Offline Rabe

Junior Newbie

« Reply #2 - Posted 2007-08-24 14:54:43 »

thanks for your help, it did work:) now it's time to continue my studies on the java 3d tutorial:)
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

orrenravid (152 views)
2016-07-16 03:57:23

theagentd (220 views)
2016-07-11 14:28:54

Hydroque (303 views)
2016-07-06 05:56:57

Hydroque (453 views)
2016-07-03 08:52:54

GrandCastle (338 views)
2016-07-01 09:13:47

GrandCastle (330 views)
2016-07-01 09:09:45

CopyableCougar4 (385 views)
2016-06-25 16:56:52

Hydroque (369 views)
2016-06-22 02:17:53

SwampChicken (336 views)
2016-06-20 13:22:57

SwampChicken (289 views)
2016-06-20 13:22:49
Making a Dynamic Plugin System
by Hydroque
2016-06-25 00:13:25

Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42

FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!