Wiki

Clone wiki

javarosa / GettingStarted

Building the J2ME Demo Project for JavaRosa

Setting up the J2ME Demo for JavaRosa is easy, but requires many steps and a programmer's expertise. Please read over this entire page first, before starting the install process. Once you start, follow the instructions carefully and use the versions we list and the install locations we suggest.

Some steps may be complicated by specific issues. Please review the details of a step before performing it to see if there are more specific instructions which are relevant to you

Notes

Before getting started, please keep the following in mind

  • Ant, not eclipse, is the build tool for JavaRosa. If eclipse shows errors, but the build.xml file works without issue, the build is fine. If eclipse is configured correctly it should not show problems, but plugins and changes make this occasionally difficult.
  • Eclipse doesn't update folders automatically when they are changed from outside Eclipse. If the tutorial mentions a file that you do not see in your Package Explorer, click on the project and refresh by pressing F5.
  • Keeping up with minor version changes is difficult, so labels and menu structures may have changed slightly. If the directions seem clear, continue with the tutorial, but please come back and update it for future users.
  • Please make sure to download the exact version of anything which mentions a version until you've had success with the basic instructions.
  • Make sure that you download 32-bit versions of both Eclipse and Java. Certain features of the emulator will not work with 64-bit Java and 64-bit Eclipse will not work with 32-bit Java. Installing a 32-bit JDK may require uninstalling previous versions.

Installing the Development Environment

  1. Install TortoiseHg.
  2. Install JDK 6.0 Update NN.
  3. Install Sun Java Wireless Toolkit for CLDC v2.5.2_01.
    1. Install to the non-default location of C:\WTK2.5.2.
  4. Install J2MEPolish-v2.1.0-- Later or earlier J2MEPolish versions will not work.
    1. If using Windows Vista or Windows 7, additional instructions should be followed here
    2. Install J2MEPolish to C:\Program Files\J2ME-Polish
      1. If you already have a different version of Polish installed additional instructions should be followed here
    3. Set the WTK directory during the install process to C:\WTK2.5.2.
  5. Install Eclipse IDE for Java Developers.
    1. Install to C:\Eclipse.
  6. Install EclipseME v1.7.9 plugin.
    1. Use Eclipse update location http://www.eclipseme.org/updates.
      1. If you are using Eclipse Galileo, you will most probably get stuck on the 'Review Licenses' screen, with the 'Finish' button disabled even though you have accepted the terms. To resolve, 'Install New Software..." -> Add Ganymede as a location: http://download.eclipse.org/releases/ganymede/.

Configuring the Development Environment

  1. Start up Eclipse and Create a new Workspace
    1. Click on File -> Switch Workspace -> Other.
    2. Specify a new folder for your JavaRosa workspace.
  2. Click on Window -> Preferences.
  3. Expand the Java ME node, go to Device Management -> Manual Install....
    1. Specify C:\WTK2.5.2 as your search directory, select Refresh and upon completion, select Finish.
    2. Double click each device listing and edit the group to read Sun Java(TM) Wireless Toolkit 2.5.2 for CLDC.
    3. Select DefaultColorPhone (or another phone of choice) as your default.
  4. Expand the Java node, and expand Build Path -> Classpath Variables.
    1. Define a new classpath variable by clicking New....
    2. Name the variable J2ME_POLISH_HOME and set its value to the installation directory of J2MEPolish (usually C:\Program Files\J2ME-Polish)
    3. Select Installed JREs from the Java node you just expanded.
    4. Click Add... -> Standard VM, and select the folder where the JDK resides (usually C:\Program Files\Java\jdk1.6.0_nn).
      1. Enter -Xmx128M into the Default VM Arguments field.
      2. Now select Finish. Enable the JDK as default by checking the checkbox.
  5. Restart Eclipse.

Downloading the Source Code

  1. Using the Windows Explorer, locate the folder you used for the JavaRosa workspace. It should contain a folder called .metadata
    1. Right click in that folder, and select TortoiseHG... -> Clone a Repository
    2. Enter the Source Path http://bitbucket.org/javarosa/javarosa. Ensure that the Destination Path is the workspace folder.
    3. Click Clone to clone the repository. This will download the JavaRosa source code.
    4. Note that your javarosa repository folder (the folder that contains .hg/) must be inside your eclipse workspace folder (the folder that contains .metadata/); if they are the same folder, you will have problems
  2. Return to Eclipse, and go to the menu File -> Import -> General -> Existing Projects into Workspace
    1. Select the javarosa folder you created and select all projects. Deselect any projects that you aren't interested in and don't need the code for your application. This will likely include everything in util/ (org.javarosa.rmstest, schema-generator, and validator-*) Make sure to deselect the "Copy files into workspace" option. If you aren't sure what to deselect, simply click Finish.
  3. Download the most recent libraries that JavaRosa depends upon from javarosa-dependencies-rNNNN.zip.
    1. Right click on the file, and select Extract.
    2. Change the path so you extract and merge into your javarosa folder.
      1. This step should go through the javarosa folder and insert jars into multiple places
  4. In Eclipse, select all projects, right click, and Refresh and wait for the refresh.
    1. Open up the javarosa-libs project, make sure it contains a number of jar files like regexp-me.jar. If not, something went wrong. Try to extract the libraries again.

Configuring the Source Code

  1. Your workspace should almost be free of errors. You will probably see the error Project 'j2me-javarosa' is missing required library: 'tools/j2merosa-libraries.jar'. Under the j2me-javarosa project.
    1. Inside of the j2me-javarosa project, open the build.properties file.
    2. Find the line containing polish.home=... and make sure it points to your J2ME-Polish installation directory
  2. Now double click build.xml in the j2me-javarosa project. This is the ant file responsible for building JavaRosa.
    1. On the right hand side of the screen you will see a pane labeled Outline.
    2. Right click on JavaRosa at the top of the outline and select Run As -> External Tools Configuration.
    3. Go to the JRE tab, and choose Separate JRE. The JDK you added earlier in the tutorial should be selected.
    4. Click Apply, then Close
  3. Now Right click on the target labeled BuildClean and select Run As -> Ant Build
    1. The build should finish, and the j2me-javarosa folder should now contain a jar called j2merosa-libraries.jar
  4. Your projects should now have no errors. If you see errors, go to Project -> Clean... -> OK.
    1. If you see a WTP Metadata error, right click on the concerned folder and choose Validate.

Running the Demo

  1. Again, under the j2me-javarosa project, double click on the build.xml file to go to the ant build script.
    1. Right click on the BuildCleanRunEmulator target in the Outline. Go to Run As... -> Ant Build.
  2. The build script will run and launch the WTK Emulator. If it does not, ask for help on the mailing list or ask to be added to the skype chat, so we can provide feedback.

Beyond the Demo

Looking through the demo source code will give you most of the information needed to build a J2MERosa application. As you become a more advanced user, you may also want to check out other javarosa projects.

To start adding new features to javarosa, rather than just building custom deployments based on the existing featureset, you'll have to start editing core code. This is the code that went into the 'j2merosa-libraries' jar used before.

Updated