Creating a new MIDlet Project

This document illustrates how to create a new MIDlet Project using MTJ.

  1. Creating a Project From Scratch
  2. Converting an existing project to an MTJ project
  3. Application Descriptor (JAD) Editor

Creating a project from scratch

In order to create a new MTJ project, use the New Project Wizard and select MIDlet Project from within the Mobile Tools for Java item.

screenshot

The first wizard pane is standard for almost all Eclipse projects. Here, you provide the name of the project, and the location for the project contents. For more information on preprocessing, refer to the preprocessing documentation.

screenshot

In the second pane, you choose which of the available device definitions you will use for compiling the project and for running and debugging. If necessary, you can change this setting later using the Project Properties. In addition, you may alter the default location for the project's JAD file on this page. The JAD file specified in this field must be created relative to the project's root folder. You may later change the JAD file later using a rename or move refactoring within the Package Explorer.

screenshot

The final pane provides you with the opportunity to adjust source settings, related projects and libraries, etc. These are standard Eclipse settings. If your project requires an external library (e.g. kXML, etc.), add the JAR file(s) to the list on the "Libraries" tab. MTJ will automatically manage these JAR files along with your compiled class files.

screenshot

Once you have completed the above steps, you will have a project that looks like this in your workspace:

screenshot

Converting an existing project to an MTJ project

If you have an existing Java project that you want to convert into an MTJ project, you can do this by selecting Convert to Midlet Project from the project pop-up menu.

screenshot

When you do this, the MTJ plug-in will automatically prompt you for the appropriate device definition, and will then make the required changes to your project.

If a J2SE project is converted to an MTJ project, the J2SE libraries need to be removed from the build path. If MTJ can identify these libraries, it will remove them automatically. If MTJ does not remove the J2SE libraries, you will need to do this yourself.

MTJ also handles adding the appropriate Java ME libraries to your project automatically. The specific libraries added are based on the selected device definition. If you were using Eclipse to do Java ME programming prior to converting your project to use MTJ, your project may still have the Java ME libraries in the build path. If so, you need to remove them. Failure to do this may cause problems, since MTJ may misinterpret these libraries as additional classes that need to be bundled into your JAR file.

Application Descriptor (JAD) Editor

After creating a new MIDlet Suite Project you may find that you need to alter the suite's properties. MIDlet Suite properties are controlled by the editing the Java Application Descriptor.