Niklas Johansson
2009-02-23 08:29:26 UTC
Hello,
I am new to Java ME and I am trying to run a copied HelloMIDlet application. I am getting following error when I am trying to run the application:
Running with storage root C:\Users\Niklas\j2mewtk\2.5.2\appdb\MediaControlSkin
Running with locale: Swedish_Sweden.1252
Running in the identified_third_party security domain
java.lang.NullPointerException
at javax.microedition.lcdui.Item.addCommandImpl(+11)
at javax.microedition.lcdui.StringItem.addCommandImpl(+11)
at javax.microedition.lcdui.Item.addCommand(+11)
at HelloMIDlet.<init>(+99)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.
3415817 bytecodes executed
17 thread switches
1667 classes in the system (including system classes)
17760 dynamic objects allocated (533540 bytes)
2 garbage collections (459436 bytes collected)
And the applicaiton:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloMIDlet extends MIDlet
implements CommandListener {
// The exit command
private Command exitCommand;
// The display for this MIDlet
private Display display;
// create a ticker
private Ticker hi = new Ticker("J2ME is cool");
public HelloMIDlet() {
display = Display.getDisplay(this);
exitCommand = new Command("Exit", Command.SCREEN, 2);
}
public void startApp() {
TextBox t = new TextBox("Hello MIDlet",
"Wireless Internet", 256, 0);
t.addCommand(exitCommand);
t.setCommandListener(this);
t.setTicker(hi); // set the ticker
display.setCurrent(t);
}
public void pauseApp() { }
public void destroyApp(boolean unconditional) { }
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
I did try to remove as much code as possible still being able to compile it. Exactly the same type of error was presented still...
I have another MIDlet in the same projects that works fine.
What is the problem?
Thank you in advance!
Best Regards,
Niklas
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx
I am new to Java ME and I am trying to run a copied HelloMIDlet application. I am getting following error when I am trying to run the application:
Running with storage root C:\Users\Niklas\j2mewtk\2.5.2\appdb\MediaControlSkin
Running with locale: Swedish_Sweden.1252
Running in the identified_third_party security domain
java.lang.NullPointerException
at javax.microedition.lcdui.Item.addCommandImpl(+11)
at javax.microedition.lcdui.StringItem.addCommandImpl(+11)
at javax.microedition.lcdui.Item.addCommand(+11)
at HelloMIDlet.<init>(+99)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.
3415817 bytecodes executed
17 thread switches
1667 classes in the system (including system classes)
17760 dynamic objects allocated (533540 bytes)
2 garbage collections (459436 bytes collected)
And the applicaiton:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloMIDlet extends MIDlet
implements CommandListener {
// The exit command
private Command exitCommand;
// The display for this MIDlet
private Display display;
// create a ticker
private Ticker hi = new Ticker("J2ME is cool");
public HelloMIDlet() {
display = Display.getDisplay(this);
exitCommand = new Command("Exit", Command.SCREEN, 2);
}
public void startApp() {
TextBox t = new TextBox("Hello MIDlet",
"Wireless Internet", 256, 0);
t.addCommand(exitCommand);
t.setCommandListener(this);
t.setTicker(hi); // set the ticker
display.setCurrent(t);
}
public void pauseApp() { }
public void destroyApp(boolean unconditional) { }
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
I did try to remove as much code as possible still being able to compile it. Exactly the same type of error was presented still...
I have another MIDlet in the same projects that works fine.
What is the problem?
Thank you in advance!
Best Regards,
Niklas
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx