开发环境:jb9+mobile3.1+motosdk(JDK的配置)
用向导新建了一个工程如下:
--------------------------------------------------------------
package a6288;
import javax.microedition.lcdui.*;
public class M extends Form implements CommandListener {
public M() {
super("主窗体");
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
setCommandListener(this);
addCommand(new Command("Exit", Command.EXIT, 1));
}
public void commandAction(Command command, Displayable displayable) {
if (command.getCommandType() == Command.EXIT) {
A6288.quitApp();
***** 此处为 jb中提示错误的地方,这是怎么回事啊?
}
}
}
编译后的错误描述:
C:\Motorola\J2ME SDK v2.0\Emulator7.5\bin\preverify.exe -cldc -classpath "D:\jbuilder 100例\A6288\classes;C:\Motorola\J2ME
SDK v2.0\Emulator7.5\lib" -d "D:\jbuilder 100例\A6288\preverified-classes" @"D:\jbuilder 100例
\A6288\preverified-classes\params"
Error preverifying class a6288.M
Class loading error: Truncated class file
====================================================================================
还有另外一个错误~~~~
根据例子写了一个简单的HelloWorld,用的是MotoSDK,编译通过,在命令行下用模拟器运行却报错:
如下:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloWorld extends MIDlet {
private Form mainScreen;
private Display myDisplay;
HelloWorld() {
myDisplay = Display.getDisplay(this);
mainScreen = new Form("哈哈");
tringItem strItem = new StringItem("这里", "程序");
mainScreen.append(strItem);
}
public void startApp() throws MIDletStateChangeException {
myDisplay.setCurrent(mainScreen);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
错误描述:Uncaught Exception: java/lang/Error (文件与模拟器在同一目录下)
这是怎么回事啊?环境变量都设置正确
如果用J2ME Wireless Toolkit 1.0.4_01运行,则有如下错误:
--------------------------------------------------------------------
Building "HelloWorld"Build completeUnable to create MIDlet HelloWorldjava.lang.IllegalAccessException at
com.sun.midp.midlet.Selector.commandAction(+50) at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+152) at
com.sun.kvem.midp.lcdui.EmulEventHandler$EventLoop.run(+459)
是不是那里配置错误啊?