我都快要急疯了!!我的j2me程序,老是出错。现附例题一则,请帮我看看:
我都快要急疯了!!我的j2me程序,用j2me wireless toolkit 可以built通过,但是run时,总是出错:null exception:java.lang.nullpointer Exception.我用的都是一些书上或网上的例题,但是都出这样的错误。
/*
* HelloWorld.java
*
* June 27, 2000
*
* ? Copyright 2000 Motorola, Inc. All Rights Reserved.
* This notice does not imply publication.
*/
package com.mot.j2me.midlets.tutorials;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
/**
* A simple Hello World midlet
*
* @see MIDlet
*/
public class HelloWorld extends MIDlet {
/**
* Main application screen
*/
private Form mainScreen;
/**
* A reference to the Display
*/
private Display myDisplay;
/**
* Creates a screen for our midlet
*/
HelloWorld() {
myDisplay = Display.getDisplay(this);
mainScreen = new Form("Hello World");
/*
* Create a string item
*/
StringItem strItem = new StringItem
("Hello", "This is a J2ME MIDlet.");
mainScreen.append(strItem);
}
/**
* Start the MIDlet
*/
public void startApp() throws MIDletStateChangeException {
myDisplay.setCurrent(mainScreen);
}
/**
* Pause the MIDlet
*/
public void pauseApp() {
}
/**
* Called by the framework before the application is unloaded
*/
public void destroyApp(boolean unconditional) {
}
}