The default Netbeans GUI builder sux by definition.
This is a small howto for the empty j2me project developing.
- File -> New Project
- Java ME -> Mobile Application -> Next
- Deselect “Create Hello MIDlet”. Finish.
That will create an empty project.
- Than add a new package with a specified name, ex. “newPackage”.
- Add a newempty Java Class file in this package, ex. “helloWorld.java”.
The example of the “helloWorld” j2me app code:
package newPackage;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class helloWorld extends MIDlet implements CommandListener{
private boolean midletPaused = false;
private Display display;
private Command cmdExit = new Command(“exitCmd”, Command.EXIT, 0);
private Form form1;
protected void destroyApp(boolean unconditional) {
}
protected void pauseApp() {
this.midletPaused = true;
}
protected void startApp() {
if (this.display == null) {
this.display = Display.getDisplay(this);
this.form1 = new Form(“newForm”);
form1.setCommandListener(this);
form1.addCommand(this.cmdExit);
this.display.setCurrent(form1);
}
this.midletPaused = false;
}
public void commandAction(Command c, Displayable d) {
if (d == this.form1) {
if (c == this.cmdExit) {
notifyDestroyed();
}
}
}
}
- Open the project properties dialog (right click on the project name).
- Application Descriptor -> MIDlet -> Add
- MIDlet Name: helloWorld (the name of the main class, better)
- MIDlet Class: newPackage.helloWorld (the ‘main’ class of the project)
- Ok.
Save, compile, build, and have fun.
P.S. Microemulator is a free cewl tool for running j2me apps on your PC.

