Setting up eclipse on Max OS X 10.5 for Java2ME development

This is how I did to compile a midlet on my Mac.

Downloaded Eclipse Pulsar, unzipped, renamed the folder to eclipse-pulsar and moved to Applications Downloaded MicroEmu from http://www.microemu.org/, unzipped it and moved the folder to /usr/local
Followed the guide here to configure and setup Eclipse Pulsar.

Downloaded the Mplayit SDK from here, unzipped it and copied the folder to /usr/local/
Open Preferences and go to JavaME->Preverification and enter this in the Preverifier field: /usr/local/mpp-sdk/osx/preverify

Downloaded ProGuard from here(4.4), unzipped it and moved it to the folder /usr/local/
Go to Java ME->Packaging->Obfuscation and enter this in the Proguard Root Directory field: /usr/local/proguard4.4

Create a new project and right click and under "Mobile Tools for Java" select Convert to MIDlet Project.

Create a new class called HelloWorld.java and enter the following code in it:

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
  public class HelloWorld extends MIDlet implements CommandListener {
    private final Command exitCommand;
    private final Form form;
      public HelloWorld() {
        exitCommand = new Command("Exit", Command.EXIT, 1);
        form = new Form("Hello World!");
        form.append("from your test MIDlet");
        form.addCommand(exitCommand);
        form.setCommandListener(this);
    }

  protected void startApp() {
        Display.getDisplay(this).setCurrent(form);
    }

  protected void pauseApp() {}

  protected void destroyApp(boolean force) {}

  public void commandAction(Command cmd, Displayable disp) {
        if (cmd == exitCommand) {
            destroyApp(false);
            notifyDestroyed();
        }
    }
}

Once saved right click on the project and selecte Mobile Tools for Java -> Create Package.

Click Application Descriptor, select the MIDlets tab in the lower part. Click Add..., enter "HelloWorld" as its name and click Browse and select HelloWorld. Select the Overview tab again and click Launch as emulated Java MIDlet. And now it should start!

Tags: , , ,

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may quote other posts using [quote] tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options