# Starting a JME3 application from the Commandline

Although we recommend the jMonkeyEngine SDK for developing JME3 games, you can use any IDE (integrated development environment) such as NetBeans or Eclipse, and even work freely from the commandline. Here is a generic IDE-independent "getting started" tutorial.

This example shows how to set up and run a simple application (HelloJME3) that depends on the jMonkeyEngine3 libraries.

The directory structure will look as follows:

    jme3/
    jme3/lib
    jme3/src
    ...
    HelloJME3/
    HelloJME3/lib
    HelloJME3/assets
    HelloJME3/src
    ...

## Installing the JME3 Framework

To install the development version of jme3,
, unzip the folder into a directory named `jme3`. The filenames here are just an example, but they will always be something like `jME3_xx-xx-2011`.

    mkdir jme3
    cd jme3
    unzip jME3_01-18-2011.zip

Alternatively, you can build JME3 from the sources. (Recommended for JME3 developers.)

    svn checkout https://jmonkeyengine.googlecode.com/svn/trunk/engine jme3
    cd jme3
    ant run
    cd ..

If you see a Test Chooser open now, the build was successful. Tip: Use `ant` to build the libraries without running the demos.

## Sample Project Directory Structure

First we set up the directory and source package structure for your game project. Note that the game project directory `HelloJME3` is on the same level as your `jme3` checkout. In this example, we create a Java package that we call `hello` in the source directory.

    mkdir HelloJME3
    mkdir HelloJME3/src
    mkdir HelloJME3/src/hello

## Libraries

Next you copy the necessary JAR libraries from the download to your project. You only have to do this set of steps once every time you download a new JME3 build. For a detailed description of the separate jar files see this list.

    mkdir HelloJME3/build
    mkdir HelloJME3/lib
    cp jme3/lib/*.* HelloJME3/lib

If you have built JME3 from the sources, then the copy paths are different:

    mkdir HelloJME3/build
    mkdir HelloJME3/lib
    cp jme3/dist/*.* HelloJME3/lib

### Sample Code

To test your setup, create the file `HelloJME3/src/hello/HelloJME3.java` with any text editor, paste the following sample code, and save.

    package hello;

    import com.jme3.app.SimpleApplication;
    import com.jme3.material.Material;
    import com.jme3.math.Vector3f;
    import com.jme3.scene.Geometry;
    import com.jme3.scene.shape.Box;
    import com.jme3.math.ColorRGBA;

    public class HelloJME3 extends SimpleApplication {

        public static void main(String[] args){
            HelloJME3 app = new HelloJME3();
            app.start();
        }

        @Override
        public void simpleInitApp() {
            Box b = new Box(Vector3f.ZERO, 1, 1, 1);
            Geometry geom = new Geometry("Box", b);
            Material mat = new Material(assetManager,
              "Common/MatDefs/Misc/Unshaded.j3md");
            mat.setColor("Color", ColorRGBA.Blue);
            geom.setMaterial(mat);
            rootNode.attachChild(geom);
        }
    }

## Build and Run

We build the sample application into the build directory???

    cd HelloJME3
    javac -d build -cp "lib/eventbus-1.4.jar:lib/j-ogg-oggd.jar:lib/j-ogg-vorbisd.jar:lib/jME3-lwjgl-natives.jar:lib/jbullet.jar:lib/jinput.jar:lib/lwjgl.jar:lib/stack-alloc.jar:lib/vecmath.jar:lib/xmlpull-xpp3-1.1.4c.jar:lib/jME3-blender.jar:lib/jME3-core.jar:lib/jME3-desktop.jar:lib/jME3-jogg.jar:lib/jME3-plugins.jar:lib/jME3-terrain.jar:lib/jME3-testdata.jar:lib/jME3-niftygui.jar:lib/nifty-default-controls.jar:lib/nifty-examples.jar:lib/nifty-style-black.jar:lib/nifty.jar:." src/hello/HelloJME3.java

??? and run it.

    cd build
    java -cp "../lib/eventbus-1.4.jar:../lib/j-ogg-oggd.jar:../lib/j-ogg-vorbisd.jar:../lib/jME3-lwjgl-natives.jar:../lib/jbullet.jar:../lib/jinput.jar:../lib/lwjgl.jar:../lib/stack-alloc.jar:../lib/vecmath.jar:../lib/xmlpull-xpp3-1.1.4c.jar:../lib/jME3-blender.jar:../lib/jME3-core.jar:../lib/jME3-desktop.jar:../lib/jME3-jogg.jar:../lib/jME3-plugins.jar:../lib/jME3-terrain.jar:../lib/jME3-testdata.jar:../lib/jME3-niftygui.jar:../lib/nifty-default-controls.jar:../lib/nifty-examples.jar:../lib/nifty-style-black.jar:../lib/nifty.jar:." hello/HelloJME3

Note: If you use Windows, the classpath separator is ";" instead of ":".

If a settings dialog pops up, confirm the default settings. You should now see a simple window with a 3-D cube. Use the mouse and the WASD keys to move. It works!

## Recommended Asset Directory Structure

For media files and other assets, we recommend creating the following project structure:

    cd HelloJME3
    mkdir assets
    mkdir assets/Interface
    mkdir assets/Materials
    mkdir assets/MatDefs
    mkdir assets/Models
    mkdir assets/Scenes
    mkdir assets/Shaders
    mkdir assets/Sounds
    mkdir assets/Textures

This will allow the default assetManager to load media files stored in the `assets` directory, like in this example:

    import com.jme3.scene.Spatial;
    ...
    Spatial elephant = assetManager.loadModel("Models/Elephant/Elephant.meshxml");
    rootNode.attachChild(elephant);
    ...

You will learn more about the asset manager and how to customize it later. For now feel free to structure your assets (images, textures, models) into further sub-directories, like in this example the `assets/models/Elephant` directory that contains the `elephant.meshxml` model and its materials.

## Next Steps

Now follow the tutorials and write your first jMonkeyEngine game.

documentation, install

view online version