Creating, building, and running the example application

In this section you create the example application from scratch. Note that this section only presents one possible way of creating the required functions.

To create a new MIDP project:

  1. In the Eclipse menu bar, select File > New > Project.

  2. Select J2ME > J2ME MIDlet suite

  3. In the window that opens, fill in the necessary project information such as the name of the project, the SDK version to be used, etc.

  4. Click Finish to complete the project creation.

  5. The project appears in Eclipse Package Explorer view.

To create source files for the project:

  1. In the Eclipse Package Explorer view, select the project you just created. Select the src folder.

  2. In the Eclipse menu bar, select File > New > Package

  3. Give the new package a name, in this case example.hello.

  4. Keep the package selected. In the Eclipse menu bar, select File > New > Class to create the HelloWorldMIDlet.java class. Repeat the step for the HelloScreen.java class.

  5. Write or copy the code in the *.java files. Save the changes, for example by closing the class and then answering yes when prompted to save changes.

To build source files for the project:

  1. In the Eclipse Package Explorer view, select the project.

  2. In the Eclipse menu bar, select Project > Build Project.

  3. Depending on the environment, the built class files can be found, for example, in a folder called preverified-temp or in a bin folder accessible in the Eclipse Package Explorer view.

To run the application:

  1. In the Eclipse Package Explorer view, right-click the project and select Run as...> Run.

  2. Create a new Run configuration for the project by selecting New and then Run.

  3. The emulator opens and the application starts.

  4. Test that the application works as described.

To deploy the application to a mobile device:

To deploy the application to a mobile device, follow the procedures described in section Deploying MIDlets to a device.