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:
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:
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
close all projects (go to the menue-bar: Window → Projects / rightclick on project name: Close Project)
go to the menue-bar:
CVS → Checkout… (NB_6: Versioning →
CVS → Checkout)
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
press >OK<
press >Next<
set MODULE: jme
set LOCAL FOLDER: MY_PATH_TO_JME_
CVS
press >Finish<
(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
When the “Checkout Completed” window appears, press >Create Project…<
press >Next<
set LOCATION: MY_PATH_TO_JME_
CVS/jme
press >Next<
press >Next<
press >Finish<
Build the jME sources
go to the menue-bar: Window → Projects
rightclick on jME: Clean and Build Project (the output must end with “BUILD SUCCESSFUL”)
rightclick on jME: Test Project (the output must end with “BUILD SUCCESSFUL”)
rightclick on jME: Generate Javadoc for Project
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
(the generation of the javadoc can take several minutes. you will find the javadoc at: MY_PATH_TO_JME_
CVS/jme/data/doc)
go to menue-bar: Tools → Library Manager (NB_6: Tools → Libraries)
press >New Library…<
press >OK<
press >Classpath<
press >Add JAR/Folder…<
navigate to: MY_PATH_TO_JME_
CVS/jme
select: build
press >Add JAR/Folder<
press >Sources<
press >Add JAR/Folder…<
navigate to: MY_PATH_TO_JME_
CVS/jme
select: src
press >Add JAR/Folder<
press >Javadoc<
press >Add ZIP/Folder…<
navigate to: MY_PATH_TO_JME_
CVS/jme/data
select: doc
press >Add ZIP/Folder<
press >New Library…<
press >OK<
press >Add JAR/Folder…<
navigate to: MY_PATH_TO_JME_
CVS/jme/lib
multi-select: jinput.jar , jogg-0.0.7.jar , jorbis-0.0.15 , lwjgl.jar
press >Add JAR/Folder<
press >OK<
The jME sources are now built and referenced.
To make a cvs-update:
To run the TestChooser:
To run the TestChooser again without recompiling:
under Linux:
under Windows:
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:
<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>
<?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>
"The processing instruction target matching "[xX][mM][lL]" is not allowed."
b) jME-Physics 2
Download the jME-Physics 2 sources
close all projects (go to the menue-bar: Window → Projects / rightclick on project name: Close Project)
go to the menue-bar:
CVS → Checkout… (NB_6: Versioning →
CVS → Checkout)
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
press >OK<
press >Next<
set MODULE: jmephysics
set LOCAL FOLDER: MY_PATH_TO_JME-PHYSICS-2_
CVS
press >Finish<
(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
When the “Checkout Completed” window appears, press >Create Project…<
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
press >Finish<
Build the jME-Physics 2 sources
go to the menue-bar: Window → Projects
rightclick on jME-Physics_2: Properties
In category Sources
press >Add Folder…< at Source Package Folders
navigate to: MY_PATH_TO_JME-PHYSICS-2_
CVS/jmephysics
multi-select: src , test , test-interactive , tutorial
press >Open<
press again >Add Folder…<
navigate to: MY_PATH_TO_JME-PHYSICS-2_
CVS/jmephysics/impl/ode
select: src
press >Open<
In the category >Libraries< (at the left), and select >Compile< (at the right)
press >Add Library…<
select: jME-compile
press >Add-Library<
press >Add JAR/Folder<
navigate to: MY_PATH_TO_JME-PHYSICS-2_
CVS/jmephysics/ant/lib
select: junit.jar
press >Open<
press >Add JAR/Folder<
navigate to: MY_PATH_TO_JME-PHYSICS-2_
CVS/jmephysics/impl/ode/lib/odejava-jni.jar
select: odejava-jni.jar
press >Open<
In the category >Libraries< (at the left), select >Run< (at the right)
press >Add Library…<
select: jME-run
press >Add Library<
In the category >Run< (at the left)
under Linux: -Djava.library.path=“MY_PATH_TO_JME_
CVS/jme/lib”:“MY_PATH_TO_JME-PHYSICS-2_
CVS/jmephysics/impl/ode/lib”
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.
press >OK<
go to the menue-bar: Window → Projects
rightclick on jME-Physics_2: Clean and Build Project (the output must end with “BUILD SUCCESSFUL”)
rightclick on jME-Physics_2: Generate Javadoc for Project
(you will find the javadoc at: MY_PATH_TO_JME-PHYSICS-2_PROJECT/jME-Physics_2/dist/javadoc)
go to menue-bar: Tools → Library Manager (NB_6: Tools → Libraries)
press >New Library…<
press >Classpath<
press >Add JAR/Folder…<
navigate to: MY_PATH_TO_JME-PHYSICS-2_PROJECT/jME-Physics_2/dist
select: jME-Physics_2.jar
press >Add JAR/Folder<
press >Sources<
press >Add JAR/Folder…<
navigate to: MY_PATH_TO_JME-PHYSICS-2_
CVS/jmephysics
select: src
press >Add JAR/Folder<
press >Javadoc<
press >Add ZIP/Folder…<
navigate to: MY_PATH_TO_JME-PHYSICS-2_PROJECT/jME-Physics_2/dist
select: javadoc
press >Add ZIP/Folder<
press >OK<
go to menue-bar: Tools → Library Manager (NB_6: Tools → Libraries)
press >New Library…<
press >Classpath<
press >Add JAR/Folder…<
navigate to: MY_PATH_TO_JME-PHYSICS-2_
CVS/jmephysics/impl/ode/lib
select: odejava-jni.jar
press >Add JAR/Folder<
press >OK<
The jME-Physics 2 sources are now built and referenced.
To make a 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:
close all projects (go to the menue-bar: Window → Projects / rightclick on project name: Close Project)
go to menue-bar: File → New Project
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
press >Finish<
Set up your new project
go to the menue-bar: Window → Projects
rightclick on your project: Properties
press >Libraries< (at the left) and >Compile< (at the right)
press >Add Library…<
multi-select: jME-compile , jME-Physics-2-compile
press >Add Library<
press >Libraries< (at the left) and >Run< (at the right)
press >Add Library…<
multi-select: jME-run , jME-Physics-2-run
press >Add Library<
press >Run< (at the left)
set VM OPTIONS:
under Linux: -Djava.library.path=“MY_PATH_TO_JME_
CVS/jme/lib”:“MY_PATH_TO_JME-PHYSICS-2_
CVS/jmephysics/impl/ode/lib”
under Windows: -Djava.library.path=“MY_PATH_TO_JME_
CVS\jme\lib”;”MY_PATH_TO_JME-PHYSICS-2_
CVS\jmephysics\impl\ode\lib”
press >OK<
Write your source code…
Compile the new project:
go to the menue-bar: Window → Projects
rightclick on your project: Clean and Build Project (the output must end with “BUILD SUCCESSFUL”)
Run the new project:
go to the menue-bar: Window → Projects
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