Eclipse Guide to jME1

WARNING: This Guide is referring to jME Version 1 (CVS) and is obsolete.

The Current jME Version is 2.x.

Introduction

This tutorial will have you up and running jME as quickly as possible. You can click the thumbnails below to view a a helpful screen-shot of each step in the instructions. Consult the Table of Contents for a specific concern, unless you are new to Eclipse, then read from the start to the end.

Configure Eclipse

Setting Eclipse to use JDK

(Note: this step is unnecessary on Mac OS X.)

You should use the newest JDK with Eclipse; download it from here: http://java.sun.com/javase/downloads/index.jsp

Select from Eclipses' main menu, Window → Preferences… → Java → Installed JREs → Add → Browse. The JDK folder is usually installed at C:\Program Files\java\, select the JDK folder and click OK → OK. Make sure the new JDK is checked, then goto Compiler and set the Compiler compliance level to its highest value, then click OK.

Note: If you already created projects, you should right-click on them → Properties → Java Complier and un-check Enable project specific settings and click OK.

Install jME

Connect to CVS

Step 1: Select from Eclipses' main menu Window → Show View → Other….
eclipse_tut_one.jpg

Step 2: Within the 'Show view' pop-up select CVSCVS Repositories → OK.
eclipse_tut_two.jpg

Step 3: Now select CVS Repositories tab → right-click in its view space → New → Repository Location….
eclipse_tut_two.jpgthree.jpg

Step 4: Enter the following parameters in the 'Add CVS Repository' pop-up to connect:

  • Host: cvs.dev.java.net
  • Repository path: /cvs
  • User: {Your java.net account or “guest” if you don't have one}
  • Password: {Your password or leave blank if guest}
  • Connection type: pserver
  • Check Save password, then click Finish

eclipse_tut_two.jpgfour.jpg

Create jME as a Java Project

Step 5: Expand the repository and HEAD tree node. This will take awhile to load, and might fail1) if you try to browse before the loading finishes. When the loading finishes, find the jme folder; either by scrolling or typing j-m-e rapidly. Then right-click on the jme folder → Check Out As….
eclipse_tut_five.jpg eclipse_tut_seven.jpg

Step 6: In the 'Check Out As' pop-up, check the option Check out as a project configured using the New Project Wizard, Checkout subfolders should already be checked, then click Finish.
eclipse_tut_alt_one.jpg

Step 7: In the 'New Project' wizard select Java Project → Next. Set the Project name to jME, make sure Create new project in workspace is checked, then click Next.
alt_three.jpg alt_four.jpg

Step 8: Click on Create new source folder, enter src for Folder name, then click Finish. Check the Allow output for source folders check box, then click Finish.
alt_five.jpg alt_six.jpg alt_seven.jpg

Step 9: Wait while you download from CVS.
eleven.jpg

Configure the jME Project

Step 10: Now right-click the jME project → Properties → Java Build Path → Libraries tab → Add Library… → User Library → Next → User Libraries… → New, enter jME required for the User library name, click OK. Select jME required → Add JARs…, browse to the folder yourworkspace/jME/lib/, then hold down the ctrl key and select:

  • jinput.jar
  • jogg-0.0.7.jar
  • jorbis-0.0.15.jar
  • junit-4.1.jar
  • lwjgl.jar
  • lwjgl-util-applet.jar

Then Expand lwjgl.jar → Native Library Location → Edit → Workspace… → expand jME → select lib → OK → OK → Finish.

Run test

Go into the jME project folder:

  • Expand the jmetest.renderer package
  • right-click on TestTeapot.java and select Run As → 1 Java application.

fourteen.jpg fifteen.jpg

Updating From CVS

Under the Package Explorer view, right-click jME project → Team → Update…, then wait for it to finish updating.

Compiling Into JARs

If you want to build jME using Ant, you will have to make sure the Virtual Machine used for compiling jME is a JDK. This is necessary because the Ant script needs to call the external java compiler which comes with the JDK.

eclipse_installed_jres.jpg

FIXME Image won't display!

To make sure a JDK is used for jME, open the Eclipse preferences dialog (Window Preferences), select Java Installed JREs and verify if the default Virtual Machine is a JDK (the checkbox near the JDK should be selected). If this is not the case, then you will have to add a JDK to the list: press Add… Browse… and select the directory where the JDK is installed. After making sure the JDK is the default VM, you may close the Preferences Dialog by pressing the “OK” button. At this point eclipse may decide to recompile some sources if you just changed the default VM, so be patient.

Expand the jME project, right-click on build.xml → Run As → 2 Ant build… → check dist-all → check dist-test → Apply → Run. After completion, you will find a list of jME JARs in the jme/target/ directory.

Adding Documentation to the JARs

If you want to see the api documentation in Eclipse when using these JARs, you need to put the source files into them. To do this you right-click on build.xml → Open, then search for:

<exclude name="**/*.java" />

Comment this line out, like so:

<!-- <exclude name="**/*.java" />  -->

Save the file, and rebuild the JAR files.

Viewing Documentation in JARs

After adding the source files to the JARs, you still need to setup Eclipse to view the source code. For each JAR, try to view a the class file, then click Attach Source… → External File, find the JAR file you were trying to view the source, select it and click Open → OK. The source should now be visible.

Using jME in Your Project

There are two ways of using jME in a separate project, you can add the jME JARs or the jME project to your build path.

Using the jME JARs

First compile the jME JARs according to the previous instructions in this tutorial.

To add the jME JARs to your projects build path, right-click your project → Properties → Java Build Path → Libraries tab → Add Library… → User Library → User Libraries → New, enter jME for the User library name. Select jME → Add JARs…, browse to the folder jME/target/, and select all the JAR files and press Open. Then Add Library… → User Library → jME required2) → OK → OK → Finish.

Using the jME Project

To add the jME project to your projects build path, right-click your project → Properties → Projects tab → Add.. → check jME → OK → OK.

Common Problems

I get a java.lang.NoClassDefFoundError on a jme class

The library containing the missing class is not in your classpath. You need to either add jme/src as a source folder in your project (if you're using a CVS checkout), or add the jME jars to your project (if you're using a jarred version).

I get a java.lang.NoSuchMethodError

You are trying to run an application that was compiled against a different version of a library you're currently using. You may have upgraded jME, LWJGL, or some other other library. To fix this, all you have to do is recompile (and possibly clean) your application with the new libraries.

Still have a problem? Visit the jME Forums. There are lots of helpful people there, ready to answer your questions.

Links

1) If CVS load failed, right-click in the view space → Refresh.
2) User library created in Step 10

/var/www/wiki/data/pages/setting_up_eclipse_to_build_jme.txt · Last modified: 2009/10/11 12:49 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