How to create J2ME midlets for Nokia using Eclipse

Here's what's needed to make a simple hello world -

  1. Get Eclipse IDE for Java. I used Ganymede. Set it up.
  2. Get Sun's Wireless Toolkit. I used 2.5.2. Install it.
  3. Get Nokia's SDK (found here), in my case for S40 6230i Edition, and install it choosing the option to integrate with Sun's WTK
  4. Follow the instructions at http://www.eclipseme.org/ to download and install Mobile Tools Java (MTJ). I used version 1.7.9.
  5. When configuring devices profiles in MTJ (inside Eclipse) use the Nokia device from the WTK folder and NOT from Nokia's folder.
  6. Set the WTK root to the main installation folder - for instance c:\WTK2.5.2; Note that the WTK installer creates other folders apparently for backward compatibility.
  7. Get Antenna and set its location in MTJ's property page (in Eclipse).

Here's an HelloWorld sample to test the configuration.

Note: It worked for me on WindowsXP. Also note: This should work for S60 as well. Just replace the S40 SDK in phase 3 with S60's.


Unless you need to do something Nokia-specific, I suggest avoiding the Nokia device definitions altogether. Develop for a generic device, then download your application to real, physical devices for final testing. The steps I suggest:

  1. Download and install Sun's Wireless Toolkit.

  2. Install EclipseME, using the method "installing via a downloaded archive".

  3. Configure EclipseME. Choose a generic device, such as the "DefaultColorPhone" to develop on.

  4. Create a new project "J2ME Midlet Suite"

  5. Right-click on the project, and create a new Midlet "HelloWorld"

  6. Enter the code, for example:

public HelloWorld() {
    super();
    myForm = new Form("Hello World!");
    myForm.append( new StringItem(null, "Hello, world!"));
    myForm.addCommand(new Command("Exit", Command.EXIT, 0));
    myForm.setCommandListener(this);
}

protected void startApp() throws MIDletStateChangeException {
    Display.getDisplay(this).setCurrent(myForm);
}

protected void pauseApp() {}

protected void destroyApp(boolean arg0) throws MIDletStateChangeException {}

public void commandAction(Command arg0, Displayable arg1) {
    notifyDestroyed();
}