Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Creating your first MIDlet using EclipseME

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: leisti (31 Jan 2008)
Last edited: hamishwillee (01 Aug 2013)

Contents

Prerequisites

We are assuming that you've installed Java ME development tools according to the article Installing Java ME development tools for Symbian.

Create a new project

  1. Start Eclipse, and go to the workbench. (If you are unaware of Eclipse concepts such as the "workbench", now is a good time to use the Help function to learn the basics.)
  2. Select the menu item File | New | Project.
  3. Expand node J2ME and select J2ME Midlet Suite. Press Next.
  4. Give the project name HelloWorld. You can also change the workspace location to be different from the default. Press Next.
  5. Select Sun Java(TM) Wireless Toolkit 2.5.2 for CLDC and DefaultColorPhone. (Selecting S60 3rd Edition FP2 SDK for MIDP and S60Device will cause running the MIDlet to fail, with an dialog displayed, saying that the Jar file could not be initialized because of a caught exception.) Press Next.
  6. In tab Source, check the checkbox Allow output folders for source folders, and accept the default.
  7. Press Finish.

Eclipse's package explorer should show a newly created project HelloWorld, which includes folders src and res, library J2ME library, and JAD file HelloWorld.jad.

Create a new MIDlet

  1. Select the menu item File | New | Other.
  2. Expand node J2ME and select J2ME Midlet. Press Next.
  3. A dialog with the title J2ME Midlet appears.
    • The Source folder setting item should already be set to <your workspace location>/src.
    • For the Package setting item, give the name com.example.helloworld.
    • For the Name setting item, give the name HelloWorldMidlet.
    • Press Finish.

You should now see a newly created file HelloWorldMidlet.java in Eclipse's editor window, with some skeleton code. Eclipse's package explorer should show that it has been created under HelloWorld/src/com.example.helloworld.


Write MIDlet code

Replace the code of HelloWorldMidlet.java with the code from article Hello World in Java ME.


Debug MIDlet code

  1. Set a breakpoint at the start of method startApp.
  2. In the Package Explorer, right-click on HelloWorldMidlet.java, select Debug As, and then Emulated J2ME Midlet.
  3. A dialog comes up asking if you want to switch to the Debug perspective. Press Yes.
  4. The phone emulator window should now be displayed. Eclipse should have switched to the Debug perspective, and in the editor window, the execution of the MIDlet should have stopped at the breakpoint you set.
  5. Resume execution. The emulator's screen should now display "Hello Hello World!"


Create a deployment package

  1. In the Package Explorer, right-click on project HelloWorld, and select J2ME | Create package or J2ME | Create Obfuscated Package.
  2. A directory HelloWorld/deployed should have been created, containing the files HelloWorld.jad and HelloWorld.jar.


See also


External links

This page was last modified on 1 August 2013, at 05:20.
147 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×