Getting started: compiling helloworld

Probably a very stupid question, but all the tutorials here seem to skip this very simple but essential step. I've copied a very very simple helloworld program, and I want to get it compiled and running.



import com.jme.app.SimpleGame;
import com.jme.math.Vector3f;
import com.jme.scene.shape.Box;


/**
 * Started Date: Jul 20, 2004<br><br>
 * Simple HelloWorld program for jME
 *
 * @author Jack Lindamood
 */
public class HelloWorld extends SimpleGame{
    public static void main(String[] args) {
        HelloWorld app=new HelloWorld();    // Create Object
        app.setConfigShowMode(ConfigShowMode.AlwaysShow);
        // Signal to show properties dialog
        app.start();    // Start the program
    }
    protected void simpleInitGame() {
        Box b=new Box("My box",new Vector3f(0,0,0),new Vector3f(1,1,1));    // Make a box
        rootNode.attachChild(b);    // Put it in the scene graph
    }
}



I'm working in Linux, doing everything in a text editor and the command line. I've put the file jME_2.0.jar in the same folder. Now I'm trying to compile and run the program:


corien@Ubuntu-Corien:~/Bureaublad/towerdefence$ ls
HelloWorld.java  jME_2.0.jar       run_jME.sh
corien@Ubuntu-Corien:~/Bureaublad/towerdefence$ javac -classpath ./:jME_2.0.jar HelloWorld.java
corien@Ubuntu-Corien:~/Bureaublad/towerdefence$ java -classpath ./:jME_2.0.jar HelloWorld
6-jul-2009 13:37:32 com.jme.app.BaseGame start
INFO: Application started.
6-jul-2009 13:37:32 com.jme.system.PropertiesGameSettings <init>
INFO: PropertiesGameSettings created
6-jul-2009 13:37:32 com.jme.system.PropertiesGameSettings load
WARNING: Could not load properties. Creating a new one.
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: [Lorg/lwjgl/opengl/DisplayMode;
   at java.lang.Class.getDeclaredMethods0(Native Method)
   at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
   at java.lang.Class.getDeclaredMethod(Class.java:1935)
   at java.awt.Component.isCoalesceEventsOverriden(Component.java:5726)
   at java.awt.Component.access$100(Component.java:162)
   at java.awt.Component$2.run(Component.java:5680)
   at java.awt.Component$2.run(Component.java:5678)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.awt.Component.checkCoalescing(Component.java:5677)
   at java.awt.Component.<init>(Component.java:5646)
   at java.awt.Container.<init>(Container.java:245)
   at java.awt.Window.<init>(Window.java:320)
   at java.awt.Window.<init>(Window.java:466)
   at java.awt.Dialog.<init>(Dialog.java:654)
   at java.awt.Dialog.<init>(Dialog.java:398)
   at javax.swing.JDialog.<init>(JDialog.java:259)
   at javax.swing.JDialog.<init>(JDialog.java:193)
   at javax.swing.JDialog.<init>(JDialog.java:141)
   at com.jme.system.lwjgl.LWJGLPropertiesDialog.<init>(LWJGLPropertiesDialog.java:184)
   at com.jme.app.AbstractGame$1.run(AbstractGame.java:236)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.opengl.DisplayMode
   at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
   ... 28 more



What am I doing wrong? How do I get my helloworld running?

In the particular case the compiler complains because it needs the lwjgl.jar as well. Have a look in

the lib-directory (I assume you downloaded the jme20_complete directory).



you have to add to your class-path this libs:

lib/lwjgl.jar lib/lwjgl_util.jar lib/lwjgl_util_applet.jar

lib/jogl.jar lib/gluegen-rt.jar lib/jinput.jar lib/jorbis-0.0.17.jar

lib/swt.jar



and additional the nativelibs-directory.



try something like this:

java -Djava.library.path=./lib/natives -classpath lib/lwjgl.jar:lib/lwjgl_util.jar:lib/lwjgl_util_applet.jar:lib/jogl.jar:lib/gluegen-rt.jar:lib/jinput.jar:lib/jorbis-0.0.17.jar:lib/swt.jar:jME_2.0.jar HelloWorld



And if you ask why that libs don't have to be specified in the batch-file. That is because of the manifest-file inside the jar that is pointing out explicitly what libaries to choose for TestChooser.class

Hope I could help and keep on rocking,
ToM


PS: Actually calling this manually is no fun! :D Why not use eclipse or Netbeans? For that have a look here:
http://www.jmonkeyengine.com/wiki/doku.php?id=setting_up_eclipse_to_build_jme_2

Thanks a lot, this was very helpfull! I finally got something up and running :).

Hello !

First, excuse my crap level in english and java :smiley:



I reply here, cause my problem is similar to Sterren : I want to compile this helloworld, with command line and emacs.



Before go throught more detailed question, these are my questions :



> What organisation of folders and files is Sterren  working on ?



I have 2 possibles options.

          1 -) The organisation obtained by fallowing all the steps @ 

                    http://www.jmonkeyengine.com/wiki/doku.php?id=chapter_1_-_getting_started

          2 -) The simple precompiled .jar files. obtained @

   



> Can you explain in detail the command : javac -classpath ./:jME_2.0.jar HelloWorld.java

      javac : pointless to explain …

      -classpath : i supposed its to tell to the compiler " Hey dude, find the JME_2.0.jar to compile plz "

      HelloWorld.java : pointless to explain …





Thanks for reading :slight_smile:

     

Hey ! Please considerer this double-post like an up }:-@

I maybe was confuse last post, so i show you my problem in details, hoping it's not too stupid !



Here :    http://www.jmonkeyengine.com/wiki/doku.php?id=simplegame

I can find a class named TestSphere.java.



I simply try to put this class in the src folder, and try to compile it with ( i think XD ) a crap command. I have no idea how to solve this.

Here are the errors ( note that i removed all the " cannot find symbol )


lenhof@lenhof-desktop:~/jme/src$ ls
com  HelloWorld.java  jmetest  TestSphere.java

lenhof@lenhof-desktop:~/jme/src$ javac TestSphere.java
TestSphere.java:12: cannot find symbol
symbol  : class AlphaState
location: package com.jme.scene.state
import com.jme.scene.state.AlphaState;
                          ^
./com/jme/system/DisplaySystem.java:41: warning: sun.misc.Service is Sun proprietary API and may be removed in a future release
import sun.misc.Service;
               ^
./com/jme/system/DisplaySystem.java:42: warning: sun.misc.ServiceConfigurationError is Sun proprietary API and may be removed in a future release
import sun.misc.ServiceConfigurationError;
               ^
./com/jme/system/DisplaySystem.java:192: warning: sun.misc.ServiceConfigurationError is Sun proprietary API and may be removed in a future release
            throws ServiceConfigurationError {
                   ^
./com/jme/system/lwjgl/LWJGLPropertiesDialog.java:65: package org.lwjgl does not exist
import org.lwjgl.LWJGLException;
                ^
./com/jme/system/lwjgl/LWJGLPropertiesDialog.java:66: package org.lwjgl.opengl does not exist
import org.lwjgl.opengl.Display;
                       ^
./com/jme/system/lwjgl/LWJGLPropertiesDialog.java:67: package org.lwjgl.opengl does not exist
import org.lwjgl.opengl.DisplayMode;
                       ^
               ^
./com/jme/input/lwjgl/LWJGLKeyInput.java:39: package org.lwjgl.input does not exist
import org.lwjgl.input.Keyboard;
                      ^
./com/jme/input/lwjgl/LWJGLKeyInput.java:40: package org.lwjgl.opengl does not exist
import org.lwjgl.opengl.Display;
                       ^
./com/jme/input/lwjgl/LWJGLMouseInput.java:45: package org.lwjgl does not exist
import org.lwjgl.LWJGLException;
                ^
./com/jme/input/lwjgl/LWJGLMouseInput.java:46: package org.lwjgl.input does not exist
import org.lwjgl.input.Cursor;
                      ^
./com/jme/input/lwjgl/LWJGLMouseInput.java:47: package org.lwjgl.input does not exist
import org.lwjgl.input.Mouse;
                      ^
./com/jme/input/lwjgl/LWJGLMouseInput.java:48: package org.lwjgl.opengl does not exist
import org.lwjgl.opengl.Display;
                       ^

./com/jme/input/joystick/lwjgl/LWJGLJoystickInput.java:37: package org.lwjgl does not exist
import org.lwjgl.LWJGLException;
                ^
./com/jme/input/joystick/lwjgl/LWJGLJoystickInput.java:38: package org.lwjgl.input does not exist
import org.lwjgl.input.Controllers;
                      ^
./com/jme/input/joystick/lwjgl/LWJGLJoystick.java:39: package net.java.games.input does not exist
import net.java.games.input.Rumbler;
                           ^
./com/jme/input/joystick/lwjgl/LWJGLJoystick.java:41: package org.lwjgl.input does not exist
import org.lwjgl.input.Controller;
                      ^

./com/jme/input/joystick/lwjgl/LWJGLJoystick.java:55: cannot find symbol
symbol  : class Controller
location: class com.jme.input.joystick.lwjgl.LWJGLJoystick
    LWJGLJoystick( Controller controller ) {
                   ^
./com/jmex/audio/openal/OpenALSystem.java:45: package org.lwjgl.openal does not exist
import org.lwjgl.openal.AL;
                       ^
./com/jmex/audio/openal/OpenALSystem.java:46: package org.lwjgl.openal does not exist
import org.lwjgl.openal.AL10;
                       ^
./com/jmex/audio/openal/OpenALSystem.java:47: package org.lwjgl.openal does not exist
import org.lwjgl.openal.OpenALException;
                       ^
./com/jmex/audio/openal/OpenALEar.java:37: package org.lwjgl.openal does not exist
import org.lwjgl.openal.AL10;
                       ^
./com/jmex/audio/openal/OpenALSource.java:35: package org.lwjgl.openal does not exist
import org.lwjgl.openal.AL10;
                       ^
./com/jmex/audio/openal/OpenALAudioBuffer.java:38: package org.lwjgl.openal does not exist
import org.lwjgl.openal.AL10;
                       ^
./com/jmex/audio/openal/OpenALAudioTrack.java:40: warning: sun.audio.AudioStream is Sun proprietary API and may be removed in a future release
import sun.audio.AudioStream;
                ^
./com/jme/util/lwjgl/LWJGLTimer.java:39: package org.lwjgl does not exist
import org.lwjgl.Sys;
                ^
./com/jme/system/lwjgl/LWJGLStandardCursor.java:39: package org.lwjgl.input does not exist
import org.lwjgl.input.Cursor;
                      ^

                  ^
./com/jmex/audio/util/AudioLoader.java:47: package com.jcraft.jorbis does not exist
import com.jcraft.jorbis.JOrbisException;
                        ^
./com/jmex/audio/util/AudioLoader.java:48: package com.jcraft.jorbis does not exist
import com.jcraft.jorbis.VorbisFile;
                        ^
./com/jmex/audio/openal/OpenALStreamedAudioPlayer.java:42: package org.lwjgl.openal does not exist
import org.lwjgl.openal.AL10;
                       ^
./com/jmex/audio/stream/OggInputStream.java:43: package com.jcraft.jogg does not exist
import com.jcraft.jogg.Packet;
                      ^
./com/jmex/audio/stream/OggInputStream.java:44: package com.jcraft.jogg does not exist
import com.jcraft.jogg.Page;
                      ^
./com/jmex/audio/stream/OggInputStream.java:45: package com.jcraft.jogg does not exist
import com.jcraft.jogg.StreamState;
                      ^
./com/jmex/audio/stream/OggInputStream.java:46: package com.jcraft.jogg does not exist
import com.jcraft.jogg.SyncState;
                      ^
./com/jmex/audio/stream/OggInputStream.java:47: package com.jcraft.jorbis does not exist
import com.jcraft.jorbis.Block;
                        ^
./com/jmex/audio/stream/OggInputStream.java:48: package com.jcraft.jorbis does not exist
import com.jcraft.jorbis.Comment;
                        ^
./com/jmex/audio/stream/OggInputStream.java:49: package com.jcraft.jorbis does not exist
import com.jcraft.jorbis.DspState;
                        ^
./com/jmex/audio/stream/OggInputStream.java:50: package com.jcraft.jorbis does not exist
import com.jcraft.jorbis.Info;
                        ^


./com/jme/system/DisplaySystem.java:195: warning: sun.misc.Service is Sun proprietary API and may be removed in a future release
            Iterator<SystemProvider> displayProviders = Service.providers(SystemProvider.class);
                                                        ^

./com/jme/system/jogl/JOGLDisplaySystem.java:55: package javax.media.opengl does not exist
import javax.media.opengl.DebugGL;
                         ^
./com/jme/system/jogl/JOGLDisplaySystem.java:56: package javax.media.opengl does not exist
import javax.media.opengl.GL;
                         ^
./com/jme/system/jogl/JOGLDisplaySystem.java:57: package javax.media.opengl does not exist
import javax.media.opengl.GLAutoDrawable;
                         ^
./com/jme/system/jogl/JOGLDisplaySystem.java:58: package javax.media.opengl does not exist
import javax.media.opengl.GLCanvas;
                         ^
./com/jme/system/jogl/JOGLDisplaySystem.java:59: package javax.media.opengl does not exist
import javax.media.opengl.GLCapabilities;
                         ^
./com/jme/system/jogl/JOGLDisplaySystem.java:60: package javax.media.opengl does not exist
import javax.media.opengl.GLContext;
                         ^
./com/jme/system/jogl/JOGLDisplaySystem.java:61: package javax.media.opengl does not exist
import javax.media.opengl.GLException;
                         ^
./com/jme/system/jogl/JOGLDisplaySystem.java:62: package javax.media.opengl does not exist
import javax.media.opengl.Threading;
                         ^
./com/jme/system/jogl/JOGLDisplaySystem.java:63: package javax.media.opengl.glu does not exist
import javax.media.opengl.glu.GLU;
                             ^
./com/jme/renderer/jogl/JOGLRenderer.java:47: package javax.media.opengl does not exist
import javax.media.opengl.GL;
                         ^
./com/jme/renderer/jogl/JOGLRenderer.java:48: package javax.media.opengl does not exist
import javax.media.opengl.GLContext;
                         ^
./com/jme/renderer/jogl/JOGLRenderer.java:49: package javax.media.opengl does not exist
import javax.media.opengl.GLException;
                         ^
./com/jme/renderer/jogl/JOGLRenderer.java:50: package javax.media.opengl.glu does not exist
import javax.media.opengl.glu.GLU;
                             ^

   
./com/jmex/awt/jogl/JOGLAWTCanvas.java:40: package javax.media.opengl does not exist
import javax.media.opengl.GLAutoDrawable;
                         ^
./com/jmex/awt/jogl/JOGLAWTCanvas.java:41: package javax.media.opengl does not exist
import javax.media.opengl.GLCanvas;
                         ^
./com/jmex/awt/jogl/JOGLAWTCanvas.java:42: package javax.media.opengl does not exist
import javax.media.opengl.GLCapabilities;
                         ^
./com/jmex/awt/jogl/JOGLAWTCanvas.java:43: package javax.media.opengl does not exist
import javax.media.opengl.GLEventListener;
                         ^

./com/jme/renderer/jogl/JOGLFont.java:37: package javax.media.opengl does not exist
import javax.media.opengl.GL;
                         ^
./com/jme/renderer/jogl/JOGLFont.java:38: package javax.media.opengl.glu does not exist
import javax.media.opengl.glu.GLU;
                             ^
./com/jme/renderer/jogl/JOGLContextCapabilities.java:38: package javax.media.opengl does not exist
import javax.media.opengl.GL;
                         ^
./com/jme/renderer/jogl/JOGLContextCapabilities.java:39: package javax.media.opengl does not exist
import javax.media.opengl.GLAutoDrawable;
                         ^
Note: ./com/jme/scene/shape/Box.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
100 errors
5 warnings



I spend so many time to just understand WHY i can't compile. I think i have to tell to the compiler where the openGL .jar files must be found.

I apologyze again for my crap english and understandment of my environment; thanks for reading and maybe helping me!  :)

NB ; Should i give more details ?

The example you are trying to build was for JME1.0 - that is why you cant find com.jme.scene.state.AlphaState; it doesn’t exist any more. See the wiki for changes from JME1 to JME2 at



http://www.jmonkeyengine.com/wiki/doku.php?id=jme_to_jme2_changes

Arf :stuck_out_tongue:



Well, i tried to build the HelloWorld from the first post, but i still have the same errors :,(