用WTK文件编译下面程序事出错
package j2meform;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class newForm extends MIDlet implements Runnable,CommandListener{
int i=0;
static newForm instance;
Display display=null;
Form f=new Form("FORM实验");
TextField tfuser=new TextField("用户名:","",10,TextField.ANY);
TextField tfpasswd=new TextField("密码:","",16,TextField.NUMERIC|TextField.PASSWORD);
Command okCommand=new Command("确定",Command.OK,1);
Gauge gauge=new Gauge("正在验证",false,5,0);
public newForm() {
instance = this;
}
public void startApp() {
if(display==null){
display=Display.getDisplay(this);
f.append(tfuser);
f.append(tfpasswd);
f.addCommand(okCommand);
f.setCommandListener(this);
}
display.setCurrent(f);
}
public void pauseApp() {
Alert alertpause=new Alert("pause","暂停ING...",null,AlertType.WARNING);
}
public void destroyApp(boolean unconditional) {
}
public static void quitApp() {
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
public void run() {
int jindu=0;
while(jindu<6){
gauge.setValue(jindu++);
try {
Thread.currentThread().sleep(1000);
} catch (InterruptedException ex) {
System.out.println("多线成出错");
ex.printStackTrace();
}
}
TextBox tb=new TextBox("已登陆","FORM实验成功",100,TextField.ANY);
display.setCurrent(tb);
}
public void commandAction(Command command, Displayable displayable) {
String struser=tfuser.getString();
String strpasswd=tfpasswd.getString();
if(struser.equals("shuchuanyu")&&strpasswd.equals("888555")){
//验证正确;
f.append(gauge);
Thread t=new Thread(this);
t.start();
}else{
//验证错误;
i++;
Alert alert=new Alert("ERROR","未通过验证!",null,AlertType.WARNING);
display.setCurrent(alert,display.getCurrent());
if(i==5)
quitApp();
}
}
}
错误:
Running with storage root C:\Documents and Settings\Administrator\j2mewtk\2.5.2\appdb\DefaultColorPhone
Running with locale: Chinese_People's Republic of China.936
Running in the identified_third_party security domain
Unable to create MIDlet newForm
java.lang.ClassNotFoundException: newForm
at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Selector.run(+22)
麻烦大家看下,谢谢~
这个问题解决了,是路径名和包名不一致的问题。可现在JAR程序在WTK里能运行,但在手机里运行就提示应用程序错误,麻烦大家在看下,谢谢了...