新人提问,不知道这个异常是怎么回事

moliliang 2010-02-06 05:26:36
一点运行的时候就提示这个异常
【Uncaught exception java/lang/Error: Static initializer: java/lang/IllegalArgumentException.】
不知道是怎么回事,以为是不是模拟器不支持。。
然后放到我的手机上测试,一运行,就提示“无法检测的异常”,然后关闭程序了。
下面是代码。。帮忙看看吧。我是看不到。。


package MIDlet;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
* @author Administrator
*/
public class StackMIDlet extends MIDlet implements CommandListener{

private static final int msgSave = 20;
private static final int max_size = 256;//URL长度

public static final String strExit = "Exit";
public static final String strPost = "Post";

public static final String strSettingTitle = "Settings";//“设置”窗口的标题
public static final String strBack = "Back";
public static final String strSave = "Save";
private TextField urlText = null;//设置

private static Display display = null;

public static final Command exit = new Command(strExit,Command.EXIT, 1);
public static final Command setting = new Command(strSettingTitle, Command.ITEM, 2);
public static final Command cmdPost = new Command(strPost, Command.OK, 3);

public static final Command cmdBack = new Command(strBack, Command.BACK, 4);
public static final Command cmdSave = new Command(strSave, msgSave, 5);

private Form SettingForm = null;//用于设置信息的窗口
private Form mainForm = null;

public StackMIDlet() {
}

public void startApp() {
if(display == null) {
display = Display.getDisplay(this);
mainForm = new Form("第一个窗口");
mainForm.addCommand(exit);
mainForm.addCommand(setting);
mainForm.setCommandListener(this);
display.setCurrent(mainForm);
}
}
//初始化“设置窗口”
private void ShowSettingForm(){
if(SettingForm != null)
return;
urlText = new TextField("服务器PHP地址:", "", max_size, TextField.URL);
SettingForm = new Form(strSettingTitle);//实例化Form窗口
SettingForm.append(urlText);
SettingForm.addCommand(cmdBack);
SettingForm.addCommand(cmdSave);
SettingForm.setCommandListener(this);
display.setCurrent(SettingForm);
}
public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable d) {
if (c == exit) {
destroyApp(false);
notifyDestroyed();
}else if (c == setting) {
ShowSettingForm();
}else if (c == cmdBack) {
//display.setCurrent(mainForm);
ShowMsg("123");
}else if (c == cmdSave) {//保存数据
char[] data = new char[max_size + 1];
urlText.getChars(data);

ReadLog log = new ReadLog();
log.AddLog(new String(data));
ShowMsg("保存成功");
}
}
private void ShowMsg(String msg){
Alert show = new Alert("提示", msg, null, AlertType.INFO);
show.setTimeout(2000);
display.setCurrent(show, mainForm);
}
}
...全文
80 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
visoeclipse 2010-02-07
  • 打赏
  • 举报
回复
那确实
网络咖啡 2010-02-06
  • 打赏
  • 举报
回复
public static final Command cmdSave = new Command(strSave, msgSave, 5);
_____
第二个参数错了
moliliang 2010-02-06
  • 打赏
  • 举报
回复
debug 了,还没进入 startapp 方法,就提示那个异常。
静态成员。。。应该不是吧。。又不是常量。。。
peter_chen_2010 2010-02-06
  • 打赏
  • 举报
回复
好像是那个静态成员初始化为NULL出错吧,我不太懂JAVA啊
水中影子 2010-02-06
  • 打赏
  • 举报
回复
参数异常。你debug看看
moliliang 2010-02-06
  • 打赏
  • 举报
回复
谢谢ls。。我知道是这个异常。。但是不知道是哪个方法传入了非法的参数。。。
pjw100 2010-02-06
  • 打赏
  • 举报
回复
非法参数异常

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧