Setting up NetBeans to build jME and jME-Physics 2

OBSOLETE PLEASE SEE [[new_frontpage]] for jME 2 Tutorials

This is a step-by-step guide that shows how to set up NetBeans IDE v5.0, v5.5 or v6.0 to use jME and jME-Physics 2. (See also Setting Up NetBeans 6.7 for JME 2.0) I hope this will help people to come over the first problems when using NetBeans. If something doesn't work, you find errors or you know how to make things better, please let me know. To get the cvs access for jME you need a java.net registration, which you can get at java.net.

In this guide I have used three dummies, which you must replace with the correct paths. Here the explanations for what they stand for:

  • MY_PATH_TO_JME_CVS : replace it with the location where you want the cvs version of jME
  • MY_PATH_TO_JME-PHYSICS-2_CVS : replace it with the location where you want the cvs version of jME-Physics 2
  • MY_PATH_TO_JME-PHYSICS-2_PROJECT: replace it with the location where you want the project data of jME-Physics 2


There are four steps:

  • a) build jME
  • b) build jME-Physics 2
  • c) Create, link, compile and run your own jME project with jME-Physics 2
  • d) How to make your game distributable


Links to the official NetBeans docs can be found here:

  • e) Links to the official netBeans docs


  • The NetBeans builtin cvs client sometimes seems to “forget” some files, so if something is not working, you should try updating from cvs again first.
  • Maybe when you read this the names of some files might have changed (for example jogg-0.0.7 could go to jogg-0.0.8), so if something will not start correctly, please check for those possible changes. Thank you.





a) jME

Download the jME sources

  1. close all projects (go to the menue-bar: Window → Projects / rightclick on project name: Close Project)
  2. go to the menue-bar: CVS → Checkout… (NB_6: Versioning → CVS → Checkout)
  3. press >Edit…<
    • set ACCESS METHOD: pserver
    • set USER: (enter your java.net user name here)
    • set HOST: cvs.dev.java.net
    • set REPOSITORY PATH: /cvs
  4. press >OK<
    • set PASSWORD: (enter your password for your java.net user name here)
  5. press >Next<
    • set MODULE: jme
    • set LOCAL FOLDER: MY_PATH_TO_JME_CVS
  6. press >Finish<
  7. (now netBeans should start to download the jME-cvs version. to see the output: go to the menue-bar: Window → Output)

Create a NetBeans project for jME

  1. When the “Checkout Completed” window appears, press >Create Project…<
    • set CATEGORIES: General
    • set PROJECTS: Java Project with Existing Ant Script (NB 6.1 Java Free-Form Project)
  2. press >Next<
    • set LOCATION: MY_PATH_TO_JME_CVS/jme
  3. press >Next<
  4. press >Next<
  5. press >Finish<

Build the jME sources

  1. go to the menue-bar: Window → Projects
  2. rightclick on jME: Clean and Build Project (the output must end with “BUILD SUCCESSFUL”)
  3. rightclick on jME: Test Project (the output must end with “BUILD SUCCESSFUL”)
  4. rightclick on jME: Generate Javadoc for Project
  5. if you get the error “The <javadoc> type doesn't support the “fork” attribute.”
    • click on the error link
    • remove the line: fork = “true”
    • close the editor window to save the changes
    • rightclick on jME: Generate Javadoc for Project
  6. (the generation of the javadoc can take several minutes. you will find the javadoc at: MY_PATH_TO_JME_CVS/jme/data/doc)
  7. go to menue-bar: Tools → Library Manager (NB_6: Tools → Libraries)
  8. press >New Library…<
    • set LIBRARY NAME: jME-compile
  9. press >OK<
  10. press >Classpath<
    1. press >Add JAR/Folder…<
    2. navigate to: MY_PATH_TO_JME_CVS/jme
    3. select: build
    4. press >Add JAR/Folder<
  11. press >Sources<
    1. press >Add JAR/Folder…<
    2. navigate to: MY_PATH_TO_JME_CVS/jme
    3. select: src
    4. press >Add JAR/Folder<
  12. press >Javadoc<
    1. press >Add ZIP/Folder…<
    2. navigate to: MY_PATH_TO_JME_CVS/jme/data
    3. select: doc
    4. press >Add ZIP/Folder<
  13. press >New Library…<
    • set LIBRARY NAME: jME-run
  14. press >OK<
  15. press >Add JAR/Folder…<
    1. navigate to: MY_PATH_TO_JME_CVS/jme/lib
    2. multi-select: jinput.jar , jogg-0.0.7.jar , jorbis-0.0.15 , lwjgl.jar
    3. press >Add JAR/Folder<
  16. press >OK<

The jME sources are now built and referenced.

To make a cvs-update:

  • go to the menue-bar: Window → Projects
  • rightclick on jME: CVS → Update (NB_6: Versioning → CVS → Update)



To run the TestChooser:

  • go to the menue-bar: Window → Projects
  • rightclick on jME: Run Project



To run the TestChooser again without recompiling:

  1. under Linux:
    • go to a console
    • enter: cd MY_PATH_TO_JME_CVS/jme/build/
    • enter: java -Djava.library.path=../lib -cp ../lib/jinput.jar:../lib/jogg-0.0.7.jar:../lib/jorbis-0.0.15.jar:../lib/lwjgl.jar:. jmetest/TestChooser
  2. under Windows:
    • go to a dos-box
    • enter: cd MY_PATH_TO_JME_CVS\jme\build
    • enter: java -Djava.library.path=..\lib -cp ..\lib\jinput.jar;..\lib\jogg-0.0.7.jar;..\lib\jorbis-0.0.15.jar;..\lib\lwjgl.jar;. jmetest.TestChooser



To Add the long missed “run” command to Your NetBeans context menue to be able to run the selected .java file from the projects src view:

  • add the following sequence to the project.xml file in the “nbproject” folder under Your project directory in the existing tag “ide-actions”:
    <action name="run.single">
       <script>nbproject/ide-file-targets.xml</script>
       <target>run-selected-file-in-src</target>
       <context>
          <property>runclass</property>
          <folder>src</folder>
          <pattern>\.java$</pattern>
          <format>java-name</format>
          <arity>
             <one-file-only/>
          </arity>
       </context>
    </action>


  • then add the file “ide-file-targets.xml” to above mentioned “nbproject” folder with following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <project basedir=".." name="jME-IDE">
    <import file="../build-import.xml"/>
    <!-- TODO: edit the following target according to your needs -->
    <!-- (more info: http://www.netbeans.org/kb/55/freeform-config.html#compilesingle) -->
       <target name="run-selected-file-in-src" description="Run Single File">
          <fail unless="runclass">Must set property 'runclass'</fail>
          <java classname="${runclass}" classpathref="classpath" fork="true">
             <classpath path="${build}"/>
             <jvmarg value='-Djava.library.path="${libs}"'/>
          </java>
       </target>
    </project>
  • If you get this error message, remove all whitespace before the first character in the file.
  "The processing instruction target matching "[xX][mM][lL]" is not allowed."
  • If libraries are not found, try removing the quotes from around “${libs}”.




b) jME-Physics 2

Download the jME-Physics 2 sources

  1. close all projects (go to the menue-bar: Window → Projects / rightclick on project name: Close Project)
  2. go to the menue-bar: CVS → Checkout… (NB_6: Versioning → CVS → Checkout)
  3. press >Edit…<
    • set ACCESS METHOD: pserver
    • set USER: (enter your java.net user name here)
    • set HOST: cvs.dev.java.net
    • set REPOSITORY PATH: /cvs
  4. press >OK<
    • set PASSWORD: (enter your password for your java.net user name here)
  5. press >Next<
    • set MODULE: jmephysics
    • set LOCAL FOLDER: MY_PATH_TO_JME-PHYSICS-2_CVS
  6. press >Finish<
  7. (now netBeans should start to download the jME-Physics 2-cvs version. to see the output: go to the menue-bar: Window → Output)

Create a NetBeans project for jME-Physics 2

  1. When the “Checkout Completed” window appears, press >Create Project…<
    • set CATEGORIES: General
    • set PROJECTS: Java Application
  2. press >Next<
    • set PROJECT NAME: jME-Physics_2
    • set PROJECT LOCATION: MY_PATH_TO_JME-PHYSICS-2_PROJECT
    • set SET AS MAIN PROJECT: no
    • set CREATE MAIN CLASS: no
  3. press >Finish<

Build the jME-Physics 2 sources

  1. go to the menue-bar: Window → Projects
  2. rightclick on jME-Physics_2: Properties
  3. In category Sources
    1. press >Add Folder…< at Source Package Folders
      1. navigate to: MY_PATH_TO_JME-PHYSICS-2_CVS/jmephysics
      2. multi-select: src , test , test-interactive , tutorial
      3. press >Open<
    2. press again >Add Folder…<
      1. navigate to: MY_PATH_TO_JME-PHYSICS-2_CVS/jmephysics/impl/ode
      2. select: src
      3. press >Open<
  4. In the category >Libraries< (at the left), and select >Compile< (at the right)
    1. press >Add Library…<
      1. select: jME-compile
      2. press >Add-Library<
    2. press >Add JAR/Folder<
      1. navigate to: MY_PATH_TO_JME-PHYSICS-2_CVS/jmephysics/ant/lib
      2. select: junit.jar
      3. press >Open<
    3. press >Add JAR/Folder<
      1. navigate to: MY_PATH_TO_JME-PHYSICS-2_CVS/jmephysics/impl/ode/lib/odejava-jni.jar
      2. select: odejava-jni.jar
      3. press >Open<
  5. In the category >Libraries< (at the left), select >Run< (at the right)
    1. press >Add Library…<
      1. select: jME-run
      2. press >Add Library<
  6. In the category >Run< (at the left)
    • set VM OPTIONS:
    1. under Linux: -Djava.library.path=“MY_PATH_TO_JME_CVS/jme/lib”:“MY_PATH_TO_JME-PHYSICS-2_CVS/jmephysics/impl/ode/lib”
    2. under Windows: -Djava.library.path=“MY_PATH_TO_JME_CVS\jme\lib”;”MY_PATH_TO_JME-PHYSICS-2_CVS\jmephysics\impl\ode\lib”

NOTE: Be VERY careful about those Quotes if you are copy-pasting into your Netbeans. Recommend that you overwrite the quotation marks by typing them in manually. The font used in the wiki seems to not be recognized in Netbeans, and you will get compilation errors because Netbeans cannot find these paths correctly.

  1. press >OK<
  2. go to the menue-bar: Window → Projects
    1. rightclick on jME-Physics_2: Clean and Build Project (the output must end with “BUILD SUCCESSFUL”)
    2. rightclick on jME-Physics_2: Generate Javadoc for Project
    3. (you will find the javadoc at: MY_PATH_TO_JME-PHYSICS-2_PROJECT/jME-Physics_2/dist/javadoc)
  3. go to menue-bar: Tools → Library Manager (NB_6: Tools → Libraries)
    1. press >New Library…<
      • set LIBRARY NAME: jME-Physics-2-compile
      • press >OK<
    2. press >Classpath<
      1. press >Add JAR/Folder…<
      2. navigate to: MY_PATH_TO_JME-PHYSICS-2_PROJECT/jME-Physics_2/dist
      3. select: jME-Physics_2.jar
      4. press >Add JAR/Folder<
    3. press >Sources<
      1. press >Add JAR/Folder…<
      2. navigate to: MY_PATH_TO_JME-PHYSICS-2_CVS/jmephysics
      3. select: src
      4. press >Add JAR/Folder<
    4. press >Javadoc<
      1. press >Add ZIP/Folder…<
      2. navigate to: MY_PATH_TO_JME-PHYSICS-2_PROJECT/jME-Physics_2/dist
      3. select: javadoc
      4. press >Add ZIP/Folder<
    5. press >OK<
  4. go to menue-bar: Tools → Library Manager (NB_6: Tools → Libraries)
    1. press >New Library…<
      • set LIBRARY NAME: jME-Physics-2-run
      • press >OK<
    2. press >Classpath<
      1. press >Add JAR/Folder…<
      2. navigate to: MY_PATH_TO_JME-PHYSICS-2_CVS/jmephysics/impl/ode/lib
      3. select: odejava-jni.jar
      4. press >Add JAR/Folder<
    3. press >OK<

The jME-Physics 2 sources are now built and referenced.

To make a cvs-update:

  • go to the menue-bar: Window → Projects
  • rightclick on jME-Physics_2: CVS → Update (NB_6: Versioning → CVS → Update)



To run Tests and Lessons:

  • go to the menue-bar: Window → Projects
  • navigate for example to: jME-Physics_2 → …/test-interactive → com.jmetest.physics
  • rightclick on TestChooser.java: Run File




c) Create, compile and run your own jME project with jME-Physics 2

Create your new project:

  1. close all projects (go to the menue-bar: Window → Projects / rightclick on project name: Close Project)
  2. go to menue-bar: File → New Project
    • set CATEGORIES: General
    • set PROJECTS: Java Application
  3. press >Next<
    • set PROJECT NAME: (enter the name of your new project)
    • set PROJECT LOCATION: (enter a directory where you want the project data)
    • set SET AS MAIN PROJECT: yes
    • set CREATE MAIN CLASS: yes
  4. press >Finish<

Set up your new project

  1. go to the menue-bar: Window → Projects
  2. rightclick on your project: Properties
    1. press >Libraries< (at the left) and >Compile< (at the right)
    2. press >Add Library…<
      1. multi-select: jME-compile , jME-Physics-2-compile
      2. press >Add Library<
    3. press >Libraries< (at the left) and >Run< (at the right)
      1. press >Add Library…<
      2. multi-select: jME-run , jME-Physics-2-run
      3. press >Add Library<
    4. press >Run< (at the left)
      • set VM OPTIONS:
        1. under Linux: -Djava.library.path=“MY_PATH_TO_JME_CVS/jme/lib”:“MY_PATH_TO_JME-PHYSICS-2_CVS/jmephysics/impl/ode/lib”
        2. under Windows: -Djava.library.path=“MY_PATH_TO_JME_CVS\jme\lib”;”MY_PATH_TO_JME-PHYSICS-2_CVS\jmephysics\impl\ode\lib”
    5. press >OK<



Write your source code…


Compile the new project:

  1. go to the menue-bar: Window → Projects
  2. rightclick on your project: Clean and Build Project (the output must end with “BUILD SUCCESSFUL”)



Run the new project:

  1. go to the menue-bar: Window → Projects
  2. rightclick on your project: Run Project




d) How to make your game distributable

After building, NetBeans will create an executable JAR file in your project's “dist” directory. Make sure there is a directory /dist/lib/ containing the jME libraries next to your jar file /lib/yourgame.jar!

If not, it may be because in one of the above steps, we added a directory full of classes as library instead of jars files. (cf Readme.txt) To fix that, do the following:

  • Open the jme project
  • In the Projects window, right-click build.xml and select “Run Target > dist-all” from the menu. It will make sure all libraries are jars and not classes.
  • Go back to your project and open the libraries folder in the Project window.
    • remove MY_PATH_TO_JME_CVS/jme/build
    • right-click Libraries and “Add Jar/Folder”: Browse to and add every JAR file from MY_PATH_TO_JME_CVS/jme/target/
  • Put all your images and 3D data files into JARs too
    • Add them to your project
    • Use Java URLs to load recources from the JAR.
      java.net.URL model=YourGame.class.getClassLoader().getResource(“data/model/myspaceship.3ds”);
  • Clean and build your project: Now you should see /dist/lib/ and the jar file should be executable.

How to create JAR files: http://www.cs.princeton.edu/introcs/85application/jar/jar.html

Forum discussion with more tips: http://www.jmonkeyengine.com/jmeforum/index.php?topic=3846.0



e) Links to the official netBeans docs

If this manual doesn't mention your problem, then you may want to take a look at:


Basixs (basixs_419@yahoo.com) 2008/03/26 13:11
Kay Gergs (justin-tmp-3d@web.de) 2007/04/05 15:40
Per Rosengren 2006/02/23 02:36
Zathras 2006/12/02 15:00


/var/www/wiki/data/pages/setting_up_netbeans_5.0_to_build_jme_and_jme-physics_2.txt · Last modified: 2010/01/24 16:50 by sbook  
Recent changes · Show pagesource · Login

Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki

subscribe to jME latest jme headlines


site design by bleedcrimson designs © 2008