初学j2me的问题,大家帮我看看吧,解决了就给分


开发环境: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)

是不是那里配置错误啊?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值