Discussion:
JAVA ME - Problems compiling and running in Eclipse
Niklas Johansson
2009-02-23 08:29:26 UTC
Permalink
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
Setera Craig
2009-02-23 11:58:04 UTC
Permalink
I'm sorry, but I don't have an answer for you. You may try a group
not focused on EclipseME, since this doesn't appear to be a problem
with the tools. You might also want to try using a newer version of
the Java ME toolkit.
Post by Niklas Johansson
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
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)
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!
Get news, entertainment and everything you care about at Live.com.
Check it out!
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San
Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the
Enterprise
-Strategies to boost innovation and cut costs with open source
participation
-Receive a $600 discount off the registration fee with the source
code: SFAD
http://p.sf.net/sfu/XcvMzF8H_______________________________________________
Eclipseme-users mailing list
https://lists.sourceforge.net/lists/listinfo/eclipseme-users
Loading...