我是J2ME的新手,我复制了一个简单的“Hello world”但是当我运行应用程序时,我得到“nullPointerException”。我在下面添加了代码和错误日志。
这是代码
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloWorld01 extends MIDlet {
private boolean paused;
private Display myDisplay;
private Hello myScreen;
public HelloWorld01() {
paused = false;
}
public void startApp() {
try {
myDisplay = Display.getDisplay(this);
myScreen = new Hello();
myDisplay.setCurrent(myScreen.pPrincipal);
} catch (Exception e) {
e.printStackTrace();
}
}
public void pauseApp() {
paused = true;
notifyPaused();
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
class Hello {
public Screen pPrincipal = new TextBox("Example", " Hello World", 50,
TextField.ANY);
}
}
这是Log
Installing suite from: file:///C:/Users/emrek/AppData/Local/Temp/_mtj.tmpemrek/Test8068677790959588786.launch/Test.jad Uncaught exception: java.lang.NullPointerException: 0 - com.sun.ams.TaskManagerHelperImpl.getTaskInfo(), bci=46 - com.sun.ams.TaskManagerHelperImpl.startTaskWithOptions(), bci=29 - com.sun.ams.TaskManagerExtImpl.startTask(), bci=6 - com.sun.midp.odd.ODTEngineBase.runMIDletSuite(), bci=12 - com.sun.midp.odd.InstallerListenerWithExecute$1.run(), bci=23 - java.lang.Thread.run(), bci=5
感谢您的帮助,