用Pulsar Eclipse开发的HelloJava程序在MOTO手机上无法运行 另:MOTODEV不识别我的E6
柯浩壤
2023-12-01
开发平台:
Pulsar Eclipse 最新版
JDK 6 update 18
JAVA ME 3.0 SDK
MOTODEV Studio 3.0 (在Pulsar中安装)
我编写了一个HelloJava程序,源代码如下:
package helloJava;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
public class HelloJava extends MIDlet {
Display display;
Form form;
public HelloJava() {
// TODO Auto-generated constructor stub
display = Display.getDisplay(this);
form = new Form("MIDlet");
StringItem item = new StringItem("Hello World!", "This is a Java ME MIDlet");
form.append(item);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
display.setCurrent(form);
}
}
执行Run as ->Emulated Java ME MIDlet,在模拟器里运行成功。
在工程上单击右键->Mobile Tools for Java->Create Package 将工程打包,生成了HelloJava.jad文件和HelloJava.jar文件。将生成的文件夹拷入我的Moto E6手机中,单击HelloJava.jar,出现文件损坏,无效文件等信息。请问这是何故?
这是HelloJava.jad文件中的内容:
MIDlet-1: HelloJava MIDlet Suite,,
MIDlet-Jar-Size: 1153
MIDlet-Jar-URL: HelloJava.jar
MIDlet-Name: HelloJava MIDlet Suite
MIDlet-Vendor: MIDlet Suite Vendor
MIDlet-Version: 1.0.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-2.1
双击生成的HelloJava.jar后,系统弹出对话框:Failed to load Main-Class manifest attribute from 我jar文件的文件路径。这又是怎么回事?
在打包后,点击工程,再点击run->run as->Emulated JAVA ME JAD后,弹出下列错误信息:
Unable to create MIDlet null
java.lang.NullPointerException
at com.motorola.moja.jsr139.vm.APPClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.sun.midp.midlet.MIDletState.createMIDlet(Unknown Source)
at com.sun.midp.midlet.Selector.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
请问大侠们这些是怎么回事?
另外我安装了MOTO USB驱动程序,安好后一切正常,用USB线将手机和电脑连接时,也显示已连接。但在Eclipse里面用MOTODEV Studio中的config tools,却无法连接我的手机。总提示Device not connected,按了刷新键以后也是一样。这又是怎么回事?和之前的打包有关系吗?希望大侠多多帮助我!我刚刚开始接触手机开发这个领域,很多东西都不懂,还望大家不吝赐教!