jME and netBeans: a starter guide - v1.0

I have written a starter guide of how to use jme and jmephysics with netBeans v4.1. I hope this will help people to come over the first problems when using netBeans. If something don'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 some dummies, which you should replace with the correct paths. Here the explanation 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_CVS : replace it with the location where you want the cvs version of jmephysics

MY_PATH_TO_JME_PHYSICS_OK : replace it with the location where you want the real version of jmephysics





There are 7 sections:



a) How to setup netBeans-cvs for jme

b) How to setup netBeans-cvs for jmephysics

c) How to compile the cvs version of jme

d) How to compile the cvs version of jmephysics

e) How to compile and run your own jme-application

f) How to compile and run your own jmephysics-application

g) Note



Maybe when you read this the names of some files might have changed (for example jogg-0.0.5 could go to jogg-0.0.6), so if something will not start correctly, please check the "VM OPTIONS" for those possible changes. Thank you.









a) How to setup netBeans-cvs for jme:


  1. go to the menue-bar: Versioning -> Versioning Manager
  2. press >Add…<
  3. set:

    VERSION CONTROL SYSTEM PROFILE: CVS

    WORKING DIRECTORY: MY_PATH_TO_JME_CVS

    CVS SERVER TYPE: pserver

    CVS SERVER NAME: cvs.dev.java.net

    PORT: 2401

    USER NAME: (enter your java.net user name here)

    REPOSITORY PATH: /cvs

    (x) to >USE BUILD-IN CVS CLIENT<

    PASSWORD: (enter your password for your java.net user name here)

    ( ) to >SET OFFLINE MODE<

    (x) to >PERFORM CHECKOUT<
  4. press >Next<
  5. press >Module(s):< and enter "jme"
  6. press >Finish<
  7. press >Close<

    8 ) now netBeans should start updating to the cvs-jme version



    To start a new update:
  8. go to the menue-bar: Window -> Versioning -> Versioning
  9. doubleclick on the correct CVS line
  10. rightclick on >jme<: CVS -> Update









    b) How to setup netBeans-cvs for jmephysics:


  11. go to the menue-bar: Versioning -> Versioning Manager
  12. press >Add…<
  13. set:

    VERSION CONTROL SYSTEM PROFILE: CVS

    WORKING DIRECTORY: MY_PATH_TO_JME_PHYSICS_CVS

    CVS SERVER TYPE: pserver

    CVS SERVER NAME: cvs.sourceforge.net

    PORT: 2401

    USER NAME: anonymous

    REPOSITORY PATH: /cvsroot/jme-physics

    (x) to >USE BUILD-IN CVS CLIENT<

    PASSWORD: (no password here)

    ( ) to >SET OFFLINE MODE<

    (x) to >PERFORM CHECKOUT<
  14. press >Next<
  15. (x) to >ALL<
  16. press >Finish<
  17. press >Close<

    8 ) now netBeans should start updating to the cvs-jmephysics version



    To start a new update:
  18. go to the menue-bar: Window -> Versioning -> Versioning
  19. doubleclick on the correct CVS line
  20. rightclick on >jmephysics<: CVS -> Update
  21. rightclick on >jme-physics-editor<: CVS -> Update









    c) How to compile the cvs version of jme:


  22. go to the menue-bar: File -> New Project…
  23. choose >General< and >Java Project with Existing Ant Script<
  24. press >Next<
  25. set LOCATION: MY_PATH_TO_JME_CVS/jme (for Linux) and MY_PATH_TO_JME_CVSjme (Windows)
  26. press >Next<
  27. press >Next<
  28. press >Add Folder…< for >SOURCE PACKAGE FOLDERS< and choose: src

    8 ) press >Finish<
  29. go to menue-bar: Windows -> Projects
  30. rightclick on jME: Clean and Build Project
  31. rightclick on jME: Test Project
  32. rightclick on jME: Generate Javadoc for Project

    (the error output is ok, the last line should be "BUILD SUCCESSFULL…")
  33. rightclick on jME: Close Project



    To compile again after a cvs-update:
  34. go to menue-bar: Open Project
  35. choose the correct project
  36. do steps 9) to 13)



    To start the tests:
  37. go to a console (Linux) or dos-box (Windows)
  38. "cd MY_PATH_TO_JME_CVS/jme/build/" (Linux) or "cd MY_PATH_TO_JME_CVSjmebuild" (Windows)
  39. under Linux enter: "java -Djava.library.path=MY_PATH_TO_JME_CVS/jme/lib -cp MY_PATH_TO_JME_CVS/jme/lib/lwjgl.jar:MY_PATH_TO_JME_CVS/jme/lib/jogg-0.0.5.jar:MY_PATH_TO_JME_CVS/jme/lib/jorbis-0.0.12.jar:. jmetest/TestChooser"

    under Windows enter: "java -Djava.library.path=MY_PATH_TO_JME_CVSjmelib -cp MY_PATH_TO_JME_CVSjmeliblwjgl.jar;MY_PATH_TO_JME_CVSjmelibjogg-0.0.5.jar;MY_PATH_TO_JME_CVSjmelibjorbis-0.0.12.jar;. jmetestTestChooser"









    d) How to compile the cvs version of jmephysics:


  40. go to the menue-bar: File -> New Project…
  41. choose >General< and >Java Application<
  42. press >Next<
  43. set PROJECT NAME: jmephysics-ok
  44. set PROJECT LOCATION: MY_PATH_TO_JME_PHYSICS_OK
  45. ( ) to >SET AS MAIN PROJECT<
  46. ( ) to >CREATE MAIN CLASS<

    8 ) press >Finish<
  47. go to menue-bar: Windows -> Projects
  48. rightclick on jmephysics-ok: Close Project
  49. delete the directory: MY_PATH_TO_JME_PHYSICS_OK/jmephysics-ok/src
  50. copy the directories "lib" and "src" from MY_PATH_TO_JME_PHYSICS_CVS/jmephysics to MY_PATH_TO_JME_PHYSICS_OK/jmephysics-ok
  51. in MY_PATH_TO_JME_PHYSICS_OK/jmephysics-ok/lib delete all except: jmetest-data.jar, junit.jar, libodejava.jnilib, libodejava.so, odejava.dll
  52. go to menue-bar: Open Project
  53. choose: jmephysics-ok
  54. go to menue-bar: Windows -> Projects
  55. rightclick on jmephysics-ok: Properties
  56. go to category >Libraries<
  57. press >Add JAR/Folder< and add all jar-files of: MY_PATH_TO_JME_PHYSICS_OK/jmephysics-ok/lib
  58. press >Add JAR/Folder< and add the directory: MY_PATH_TO_JME_CVS/jme/build
  59. press >Add JAR/Folder< and add all jar-files of: MY_PATH_TO_JME_CVS/jme/lib
  60. go to category >Run<
  61. set VM OPTIONS:

    under Linux: "-Djava.library.path=MY_PATH_TO_JME_CVS/jme/lib:MY_PATH_TO_JME_PHYSICS_OK/jmephysics-ok/lib -cp MY_PATH_TO_JME_CVS/jme/lib/lwjgl.jar:MY_PATH_TO_JME_CVS/jme/lib/jogg-0.0.5.jar:MY_PATH_TO_JME_CVS/jme/lib/jorbis-0.0.12.jar:MY_PATH_TO_JME_PHYSICS_OK/jmephysics-ok/lib/jmetest-data.jar:MY_PATH_TO_JME_PHYSICS_OK/jmephysics-ok/lib/junit.jar"

    under Windows: "-Djava.library.path=MY_PATH_TO_JME_CVSjmelib;MY_PATH_TO_JME_PHYSICS_OKjmephysics-oklib -cp MY_PATH_TO_JME_CVSjmeliblwjgl.jar;MY_PATH_TO_JME_CVSjmelibjogg-0.0.5.jar;MY_PATH_TO_JME_CVSjmelibjorbis-0.0.12.jar;MY_PATH_TO_JME_PHYSICS_OKjmephysics-oklibjmetest-data.jar;MY_PATH_TO_JME_PHYSICS_OKjmephysics-oklibjunit.jar"
  62. press >Ok<
  63. rightclick on jmephysics-ok: Clean and Build Project
  64. rightclick on jmephysics-ok: Generate Javadoc for Project

    (the error output is ok, the last line should be "BUILD SUCCESSFULL…")
  65. rightclick on jmephysics-ok: Close Project





    To compile again after a cvs-update:
  66. delete the directory: MY_PATH_TO_JME_PHYSICS_OK/jmephysics-ok/lib
  67. do steps 11) to 16) and 25) to 27)





    To start the tests:
  68. go to menue-bar: Open Project
  69. choose: jmephysics-ok
  70. go to menue-bar: Windows -> Projects
  71. doubleclick on: jmephysics-ok
  72. doubleclick on: Source Packages
  73. doubleclick on: jmextest.physics
  74. rightclick on SimpleTest.java -> Run File









    e) How to compile and run your own jme-application:


  75. go to the menue-bar: File -> New Project…
  76. choose >General< and >Java Application<
  77. press >Next<
  78. set PROJECT NAME: my-own-jme-application
  79. set PROJECT LOCATION: (set the location you want)
  80. (x) to >SET AS MAIN PROJECT<
  81. (x) to >CREATE MAIN CLASS<

    8 ) press >Finish<
  82. go to menue-bar: Windows -> Projects
  83. rightclick on my-own-jme-application: Properties
  84. go to category >Libraries<
  85. press >Add JAR/Folder< and add the directory: MY_PATH_TO_JME_CVS/jme/build
  86. press >Add JAR/Folder< and add all jar-files of: MY_PATH_TO_JME_CVS/jme/lib
  87. go to category >Run<
  88. set VM OPTIONS:

    under Linux: "-Djava.library.path=MY_PATH_TO_JME_CVS/jme/lib -cp MY_PATH_TO_JME_CVS/jme/lib/lwjgl.jar:MY_PATH_TO_JME_CVS/jme/lib/jogg-0.0.5.jar:MY_PATH_TO_JME_CVS/jme/lib/jorbis-0.0.12.jar"

    under Windows: "-Djava.library.path=MY_PATH_TO_JME_CVSjmelib -cp MY_PATH_TO_JME_CVSjmeliblwjgl.jar;MY_PATH_TO_JME_CVSjmelibjogg-0.0.5.jar;MY_PATH_TO_JME_CVSjmelibjorbis-0.0.12.jar"
  89. press >Ok<
  90. for an example delete the whole source code (except the line "package…") from Main.java which you should see in the Document Window (menue-bar: Window -> Switch to Document)
  91. now copy the source of: MY_PATH_TO_JME_CVS/jme/src/jmetest/TutorialGuide/HelloWorld.java (except the line "package…") into Main.java
  92. rename in Main.java all "HelloWorld" to "Main"
  93. rightclick on my-own-jme-application: Clean and Build Project
  94. rightclick on my-own-jme-application: Run Project









    f) How to compile and run your own jmephysics-application:


  95. go to the menue-bar: File -> New Project…
  96. choose >General< and >Java Application<
  97. press >Next<
  98. set PROJECT NAME: my-own-jmephysics-application
  99. set PROJECT LOCATION: (set the location you want)
  100. (x) to >SET AS MAIN PROJECT<
  101. (x) to >CREATE MAIN CLASS<

    8 ) press >Finish<
  102. go to menue-bar: Windows -> Projects
  103. rightclick my-own-jmephysics-application: Properties
  104. go to category >Libraries<
  105. press >Add JAR/Folder< and add the directory: MY_PATH_TO_JME_CVS/jme/build
  106. press >Add JAR/Folder< and add all jar-files of: MY_PATH_TO_JME_CVS/jme/lib
  107. press >Add JAR/Folder< and add the directory: MY_PATH_TO_JME_PHYSICS_OK/jmephysics-ok/build/classes
  108. go to category >Run<
  109. set VM OPTIONS:

    under Linux: "-Djava.library.path=MY_PATH_TO_JME_CVS/jme/lib:MY_PATH_TO_JME_PHYSICS_OK/jmephysics-ok/lib -cp MY_PATH_TO_JME_CVS/jme/lib/lwjgl.jar:MY_PATH_TO_JME_CVS/jme/lib/jogg-0.0.5.jar:MY_PATH_TO_JME_CVS/jme/lib/jorbis-0.0.12.jar"

    under Windows: "-Djava.library.path=MY_PATH_TO_JME_CVSjmelib;MY_PATH_TO_JME_PHYSICS_OKjmephysics-oklib -cp MY_PATH_TO_JME_CVSjmeliblwjgl.jar;MY_PATH_TO_JME_CVSjmelibjogg-0.0.5.jar;MY_PATH_TO_JME_CVSjmelibjorbis-0.0.12.jar"
  110. press >Ok<
  111. for an example delete the whole source code (except the line "package…") from Main.java which you should see in the Document Window (menue-bar: Window -> Switch to Document)
  112. now copy the source of: MY_PATH_TO_JME_PHYSICS_OK/jme-physics-ok/src/jmextest/physics/SimpleTest.java (except the line "package…") into Main.java
  113. rename in Main.java all "SimpleTest" to "Main"
  114. rightclick on my-own-jmephysics-application: Clean and Build Project
  115. rightclick on my-own-jmephysics-application: Run Project









    g) Note:



    Since jME has its own ant build script, it must be a netBeans free-form IDE project. As a reason of this i don't know how to add the sources of jME in step e) and f), so that you can't rightclick on for example setDialogBehaviour (-> Go To -> Source) to jump to the source-code. As an impure solution for this you can do the following steps. If someone knows a better way, please let me know:


  116. go to menue-bar: Tools -> Java Platform Manager
  117. press on "Sources"
  118. press >Add JAR/Folder…<
  119. choose: MY_PATH_TO_JME_CVS/jme/src
  120. press >Close<

Go to www.jmonkeyengine.com/wiki, create an account and post this there in the articles section by the eclipse one. We don't want to lose this as the posts bury it. Good job.

Good idea, i will do it the next days.

to be able to run the tests from withhin netbeans i checked out from cvs into a readonly jme folder and created a new java project with existing sources in another folder besides jme so it makes its own build.xml and builds into this new folder (jme-nb-project) so i can build and run from the ide without having to set the checkout to rw.

but the libs / classpath / librarypath in project.properties has to be set accordingly.



I've tried to add a NB specific run target to the jme build.xml some time ago which would have been a better solution, but gave up then.

maybe it's time to give it another shot now :slight_smile:

@winkman: it would be nice to have that



@mojomonk: it's in the wiki

Now i have found out how to force a linefeed in the wiki :smiley:



It's the: \

Ok, took some time but here is a testchooser run target for jme build.xml which simply launches the testchooser app so You can select Your test of choice from that.

It should work IDE independent but as it uses fork i hope it uses the same jdk as ant does ?

Still have to do a NetBeans specific run-netbeans target that runs the marked main class in NetBeans…





<target name="run-testchooser" depends="dist-test" description="Runs the TestChooser (or at least trys to do so :)">
        <java classname="jmetest.TestChooser" fork="true"  classpath="${jars}/jmetest.jar:${jars}/jmetest-data.jar:${jars}/jme.jar:${jars}/jme-effects.jar:${jars}/jme-model.jar:${jars}/jme-terrain.jar:${jars}/jme-ui.jar:${jars}/jme-sound.jar:${seg}/lib/lwjgl.jar:${seg}/lib/lwjgl_fmod3.jar:${seg}/lib/jogg-0.0.5.jar:${seg}/lib/jorbis-0.0.12.jar">
            <jvmarg value='-Djava.library.path="${libs}"'/> 
        </java>
</target>

I changed it a little bit, but the build.xml contains a 'run-testchooser' target, now.

Thanks for putting it in :slight_smile:

But unfortunately i didn’t test it on linux and it can’t find the native libs there :frowning:



to work on linux both, the jvmarg argument should be:


 <jvmarg value="-Djava.library.path=${libs}"/>



sorry for that
Martin

Ok, i got a NetBeans specific one main-file run-target ready.

But it requires a netbeans-specific project file to be in the project or being modified manually. (/nbproject/project.xml)

This means this would be a really specific thing that probably would only work for NetBeans 4.1.



So my question: is it desirable to put the build.xml - part in cvs and maybe the nb only project.xml too ?



If not i will post the setup - procedure for NB 4.1 on the wiki after i have had time to complete the compile-single and debug-single targets too.

well done!

MrCoder said:

well done!


Thank you :)

I have rewritten the step-by-step guide for setting up netbeans 5.0 to build jME and jME-Physics 2. It is better than the old one and up-to-date i hope.



Here is a direct link: http://www.jmonkeyengine.com/wiki/doku.php?id=setting_up_netbeans_5.0_to_build_jme_and_jme-physics_2



Best wishes



justin

justin said:

and jME-Physics 2

cool! good work!

Only a minor thing I have spotted: the layout of the command lines under "To run the TestChooser again without recompiling" is a little strange (don't know why though).
irrisor said:
Only a minor thing I have spotted: the layout of the command lines under "To run the TestChooser again without recompiling" is a little strange (don't know why though).


This is because the text is formatted as a block and i don't know how to change it. I will try it again tomorrow.

Good night.