Time for action – creating a project

The jMonkeyEngine SDK provides you with a preconfigured project template that gets you started at lightning speed.

This is how you create a new project:

  1. Choose File | New Project from the menu
  2. Select BasicGame from the jME3 category.
  3. You can rename the project here, but for now, accept the defaults and complete the wizard.

A new Java project named BasicGame appears in the Projects window, next to the JME3 Tests project.

The BasicGame project contains a simple Main.java template. Let's try to run this Java application:

  1. Open the BasicGame project's Source Packages, and double-click on the mygame/Main.java file to open it. You see that the JDK contains a full-featured editor for Java files.
  2. Right-click on the BasicGame project and click on Build and Run.
  3. Accept the default display settings and click on OK.
  4. The application window opens and shows a blue 3D cube on a black background. If this works, you know that your project is set up correctly.
  5. Press the Esc key to quit the BasicGame project's window.

As you can see, it's easy to create and run fully preconfigured game projects in the jMonkeyEngine SDK.

What just happened?

Let's open the BasicGame folder in the Projects window and look at the project structure that the SDK has just created for you.

You can see that the Projects window gives you access to three important areas: Project Assets, Source Packages, and Libraries, as well as the build script.

The Projects window shows the logical structure of a jMonkeyEngine project. This view only displays files that you need during development, and it filters out build folders and configuration files. For comparison, have a look at the project's physical structure, which lets you browse the actual files on your hard drive; choose Window | Files from the menu to open the Files window. Click the triangles to open the subsections and compare the two views, as shown in the previous screenshot.

Browse the Libraries section in the Projects window. You can see that it lists all the JAR files that are preconfigured on this project's CLASSPATH. Compare this to the physical dist/lib directory in the Files window.

If you know about Ant build scripts, you may want to open the Important Files node in the Projects window and browse the preconfigured Ant targets. Compare this to the physical build file, build.xml in the Files window.

You will see that a jMonkeyEngine-based application is a standard Java project made up of the following files and folders:

Certain files and folders are automatically created and maintained by the jMonkeyEngine SDK such as build, dist, and nbproject. The SDK recreates these files and folders when you build the application, so do not edit them.

The other folders, highlighted in yellow, contain your sources and assets. Using the test folder is optional; for now, just ignore it. As in any Java project, you have full control over the project's build.xml file, and your two main folders, assets and src.

Switch back to the Projects window. You see that the Project Assets folder corresponds to jMonkeyProjects/BasicGame/assets/, and the Source Packages folder corresponds to jMonkeyProjects/BasicGame/src/. You are free to set up subfolders and packages inside these two folders, as your project requires.

Your Java classes obviously go into Source Packages, but what does the Project Assets folder contain? Open the Project Assets folder and look inside: you will see subfolders for Sounds, Textures, and Models. This folder is where you store your multimedia content.