Results 1 to 8 of 8
  1. #1
    secesh is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Java3d Issues from Command prompt.

    Ok guys when I am using java3d from NetBeans everything works perfectly when I include those libraries. Look at this snap shot below.
    Java3d Issues from Command prompt.-ss1.png

    Ok now it works there. But when I run a program from command prompt using javac I get this.
    Java3d Issues from Command prompt.-ss6.png

    It's almost like the path is not set. However I've set it in control panel like so.
    Java3d Issues from Command prompt.-ss3.png

    I checked the path in command prompt and it is listed the following paths which are correct. Guys why in the world does it run in NetBeans but not command prompt. I'm loosing my mind I've worked on this for 5 hours!
    Java3d Issues from Command prompt.-ss4.png

    Here is the code.
    Java Code:
    package hello3d;
    
    import java.awt.*;
    import javax.swing.*;
    
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.ColorCube;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    
    
    public class Hello3d extends JFrame
    {
    
      public Hello3d()
      {
        // create a Swing panel inside the JFrame
        JPanel p = new JPanel();
        p.setLayout( new BorderLayout() );
        p.setPreferredSize( new Dimension(250, 250) );
        getContentPane().add(p, BorderLayout.CENTER);
    
        // add the 3D canvas to panel
        Canvas3D c3d = createCanvas3D();
        p.add(c3d, BorderLayout.CENTER);
    
        // configure the window (JFrame)
        setTitle("HelloUniverse");
        setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );
        pack();
        setVisible(true);
      }  // end of HelloUniverse()
    
    
    
      private Canvas3D createCanvas3D()
      /* Build a 3D canvas holding a SimpleUniverse which contains
         our 3D scene (a rotating colored cube) */
      {
        // get the preferred graphics configuration for the default screen
        GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
    
        // create a Canvas3D using the preferred configuration
        Canvas3D c3d = new Canvas3D(config);
    
        // create a simple universe
        SimpleUniverse univ = new SimpleUniverse(c3d);
    
        // move the camera back a bit so the cube can be seen
        univ.getViewingPlatform().setNominalViewingTransform();
    
        // ensure at least one redraw every 5 ms
        univ.getViewer().getView().setMinimumFrameCycleTime(5);
    
        // add the scene to the universe
        BranchGroup scene = createSceneGraph();
        univ.addBranchGraph(scene);
    
        return c3d;
      }  // end of createCanvas3D()
    
    
      public BranchGroup createSceneGraph()
      /* The scene graph is:
             scene ---> tg ---> colored cube
                   |
                   ---> rotator
      */
      { 
        BranchGroup scene = new BranchGroup();
    
        /* Create a TransformGroup node. Enable its TRANSFORM_WRITE 
           capability so it can be affected at run time */
        TransformGroup tg = new TransformGroup();
        tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        scene.addChild(tg);   // add to the scene 
    
        // connect a coloured cube to the TransformGroup
        tg.addChild( new ColorCube(0.4) );
    
        /* Create a rotation behaviour (a rotation interpolator) which will
           make the cube spin around its y-axis, taking 4 secs to do one
           rotation. */
        Transform3D yAxis = new Transform3D();
        Alpha rotationAlpha = new Alpha(-1, 4000);   // 4 secs
        RotationInterpolator rotator = 
                    new RotationInterpolator(rotationAlpha, tg, 
                                        yAxis, 0.0f, (float) Math.PI*2.0f);
        rotator.setSchedulingBounds(
                             new BoundingSphere( new Point3d(0,0,0), 100.0) );
        scene.addChild(rotator);    // add to the scene
    
        // optimize the scene graph
        scene.compile();
        return scene;
      }  // end of createSceneGraph()
    
    
    
      // ------------------------------------------------------------
    
      public static void main(String args[])
      {  new Hello3d();  }
        
        
    } // end of HelloUniverse class
    Attached Thumbnails Attached Thumbnails Java3d Issues from Command prompt.-ss2.png  

  2. #2
    secesh is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Re: Java3d Issues from Command prompt.

    Ok gentlemen I got this bad boy to link. with

    javac -cp j3dutils.jar;j3dcore.jar;vecmath.jar Hello3d.java

    Now when I run java -cp j3dutils.jar;j3dcore.jar;vecmath.jar Hello3d it says cannot find or load main class Hello3d.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,942
    Rep Power
    30

    Default Re: Java3d Issues from Command prompt.

    Add a . (dot) to the -cp option so the java program will look in the current directory for the Hello2d class file:
    java -cp .;j3dutils.jar;j3dcore.jar;vecmath.jar Hello3d
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    secesh is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Re: Java3d Issues from Command prompt.

    Same error when running java -cp .;j3dutils.jar;j3dcore.jar;vecmath.jar Hello3d

  5. #5
    secesh is offline Member
    Join Date
    Mar 2017
    Posts
    4
    Rep Power
    0

    Default Re: Java3d Issues from Command prompt.

    Holy hell brother I got it. When I copied over the code from NetBeans I left
    package hello3d;
    in. Your command works perfect now. Thanks a million.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    25

    Default Re: Java3d Issues from Command prompt.

    You don't want to remove the package.
    It is generally a bad thing to not have your code in packages.

    So, with the package, the compilation call is (from the directory containing the hello3d directory):
    javac -cp .;<your other dependencies> hello3d/Hello3d

    Then, to run it, (again from the directory containing the hello3d directory):
    javac -cp .;<your other dependencies> hello3d.Hello3d
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,942
    Rep Power
    30

    Default Re: Java3d Issues from Command prompt.

    The java command would be used to execute/run the class.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    25

    Default Re: Java3d Issues from Command prompt.

    Oops!
    Typo!
    Thanks, Norm.

    Should have been:
    java -cp .;<your other dependencies> hello3d.Hello3d
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Unsafe or unchecked errors in Command prompt issues
    By zlloyd1 in forum New To Java
    Replies: 1
    Last Post: 12-12-2012, 09:01 AM
  2. Letting my program command the command prompt
    By Smokey. in forum Threads and Synchronization
    Replies: 4
    Last Post: 03-29-2011, 11:34 PM
  3. New Command prompt
    By jmga9 in forum New To Java
    Replies: 4
    Last Post: 11-10-2010, 01:53 AM
  4. log message from command prompt
    By tedy2808 in forum New To Java
    Replies: 5
    Last Post: 08-25-2010, 11:04 AM
  5. help me!!!! about command prompt..
    By kureikougaiji in forum New To Java
    Replies: 2
    Last Post: 11-13-2008, 06:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •