捡分题……HelloWorld 大家快来
我是新手
先安装了jdk1.5 然后安装了WTK
然后按照书上的写了个HelloWorld
代码如下:
package HelloWorld;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloWorldMIDlet extends MIDlet implements CommandListener{
private Display display;
private Form props;
private Command exitCommand = new Command("EXIT",Command.Exit,1);
public HelloWorldMIDlet(){
display = Display.getDisplay(this);
}
public void startApp(){
props = new Form("Hello World!!!!");
props.append("Hello World!\n");
props.addCommand(exitCommand);
props.setCommandListener(this);
display.setCurrent(props);
}
public void commandAction(Command c, Displayable s){
if(c == exitCommand){
destroyApp(false);
notifyDestroyed();
}
}
public void destroyApp(boolean unconditional){
}
public void pauseApp(){
}
}
错误提示出现在声明Command处:
d:\WTK22\apps\HelloWorld\src\HelloWorld\HelloWorldMIDlet.java:9: cannot find symbol
symbol : variable Exit
location: class javax.microedition.lcdui.Command
private Command exitCommand = new Command("EXIT",Command.Exit,1);
^
d:\WTK22\apps\HelloWorld\src\HelloWorld\HelloWorldMIDlet.java:9: internal error; cannot instantiate Command(java.lang.String,int,int) at javax.microedition.lcdui.Command to ()
private Command exitCommand = new Command("EXIT",Command.Exit,1);
^
2 errors
com.sun.kvem.ktools.ExecutionException
生成失败