请教,在WTK中 运行项目时出错,得不到预期的结果?
这个例子是 <<手把手教你写第一个J2ME手机程序>>中的例子,在生成项目成功后,
用鼠标点击“launch”字样下方的按钮,结果并没有象预期的一样,在屏幕的中出现了“Hello World...”的字样,
而出现错误如下:
Project "helloworld" loaded
Project settings saved
Building "helloworld"
Build complete
Running with storage root DefaultColorPhone
Uncaught exception java/lang/NoClassDefFoundError: helloworldmidlet.
等赐教,将不甚感谢!
/*文件一HelloWorldMIDlet.java */
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloWorldMIDlet extends MIDlet implements CommandListener{
private HelloWorldCanvas Canvas;
public void startApp(){
if(Canvas==null){
Canvas = new HelloWorldCanvas(Display.getDisplay(this));
Command exitCommand = new Command("Exit",Command.EXIT,0);
Canvas.addCommand(exitCommand);
Canvas.setCommandListener(this);
}
Canvas.start();
}
public void pauseApp(){
}
public void destroyApp(boolean uncoditional){
}
public void commandAction(Command c,Displayable s){
if(c.getCommandType()==Command.EXIT){
destroyApp(true);
notifyDestroyed();
}
}
}
/*文件二 HelloWorldCanvas.java */
import javax.microedition.lcdui.*;
public class HelloWorldCanvas extends Canvas{
private Display display;
public HelloWorldCanvas(Display d){
display = d;
}
public void start(){
display.setCurrent(this);
repaint();
}
public void paint(Graphics g){
g.setColor(128,128,256);
g.fillRect(0,0,getWidth(),getHeight());
g.setColor(255,0,0);
int y = 20;
String helloWorld = "Hello World,this is my j2me";
g.drawString(helloWorld,0,y,Graphics.TOP ¦Graphics.LEFT);
}
}