Unable to create MIDlet null

A simple sample program from "Wireless java" by Jonathan knudsen. Couldn't go through.

I tried use both wireless tool kit(1.0.3 beta) and

command line, I can compile with no problem, Jar got

generated, but when I launch it from emulator, it gives

error like:

Unable to create MIDlet null

java.lang.NullPointerException

at com.sun.midp.midlet.Selector.commandAction(+47)

at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+144)

at com.sun.kvem.midp.lcdui.EmulEventHandler$EventLoop.run(+427)

I also have some samples from that book give me exactly the same messages. But still some programs from that book work fine as well as examples come with wireless tool kit.

Big confusion! Great appreciate for any help!

code:

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

public class Commander extends MIDlet {

public void startApp() {

Displayable d = new TextBox("TextBox", "Commander", 20, 0);

Command c = new Command("Exit", Command.EXIT, 0);

d.addCommand(c);

d.setCommandListener(new CommandListener() {

public void commandAction(Command c, Displayable s) {

notifyDestroyed();

}

});

Display.getDisplay(this).setCurrent(d);

}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

}

[1460 byte] By [raybao] at [2007-9-26 9:00:46]
# 1

[raybao],

I just took the code you posted and tested it on my installed J2ME Wireless Toolkit 1.0.3 BETA on a Solaris machine with the J2SE SDK 1.3.1 and it works fine.

The app shows me a TexBox with the string "Commander" in it and when the Select button of the emulator is selected, the text gets displayed on the emulated device screen.

I am suspecting that the problem you are seeing has something to do with the JDK you installed on your machine. What is the version of the JDK and on what OS platform are you testing this on?

Allen Lai

Developer Technical Support

SUN Microsystems

http://www.sun.com/developers/support/

allenlai at 2007-7-1 20:03:02 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

Thank you for your help.

I installed Wireless toolket 1.0.3 beta on windows98

with JDKSE1.3.1. Actually, The first thing I installed were JDKSE1.4 beta and wireless toolkit 1.0.3 beta,

wireless toolkit couldn't work at all. Then I installed

JDKSE1.3.1 and re-install toolkit 1.0.3 beta again. Now

in some cases it works.

Probaly I didn't remove JDK1.4 entirelly, maybe runtime

enverioment is still 1.4?

One strange thing is I have a sample program from that

book, I create a project from ktool with same name

as the publc Midlet class name in that program. I can

compile and run it with no problem. Then I created another project, and copied that program to new project's src directory, rename the file name to the new

project name and change class name in the source code

to project name as well.I can compile this new project, but when I load it and launch it , it gives me

the same error information as I mentioned before.

It looks to me that program can only work with that

particular class name!

raybao at 2007-7-1 20:03:02 > top of Java-index,Java Mobility Forums,Java ME Technologies...