Eclipse+eclipseME+WTK2.5 配置J2ME开发环境
-
下载ECLIPSE(我下载的是eclipse 3.3)
http://www.eclipse.org/downloads/
-
下载WTK2.5
http://java.sun.com/products/sjwtoolkit/download-2_5_1.html
-
下载 eclipseME
http://eclipseme.org/
-
给ECLIPSE安装eclipseME插件
1.ECLIPSE->WINDOWS->PREFERENCES->J2ME 添加WTK的PATH
2.安装DEVICE
ECLIPSE->WINDOWS->PREFERENCES->J2ME->Device Management->Import
(新手,选中WTK路径,记得refresh)
3.为了在ECLIPSE下可以DEBUG
ECLIPSE->WINDOWS->PREFERENCES->JAVA -> Debug
去掉Suspend execution on uncaught exceptions和Suspend execution on compilation errors
并设置Debugger timeout(ms)到15000
4. 让我们开始开发之旅:
@File -> New -> Others -> J2ME -> J2ME MIDLET SUITE
@输入Project Name (比如: Demo)
@选中Project(Demo)
@File -> New -> Others -> J2ME -> J2ME MIDLET
@输入类名: DemoHelloWorld
-
import javax.microedition.lcdui.Command;
-
import javax.microedition.lcdui.CommandListener;
-
import javax.microedition.lcdui.Display;
-
import javax.microedition.lcdui.Displayable;
-
import javax.microedition.lcdui.TextBox;
-
import javax.microedition.midlet.MIDlet;
-
import javax.microedition.midlet.MIDletStateChangeException;
-
-
public class DemoHelloWorld extends MIDlet implements CommandListener {
-
private Display display;
-
private TextBox textBox;
-
private Command quitCommand;
-
public DemoHelloWorld() {
-
// TODO Auto-generated constructor stub
-
}
-
-
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=Display.getDisplay(this);
-
quitCommand= new Command("Quit",Command.SCREEN,1);
-
textBox = new TextBox("Goodbye World","My second MIDlet",500,0);
-
textBox.addCommand(quitCommand);
-
textBox.setCommandListener(this);
-
display.setCurrent(textBox);
-
-
}
-
-
public void commandAction(Command choice, Displayable displayable){
-
if(choice==quitCommand){
-
try {
-
destroyApp(false);
-
notifyDestroyed();
-
} catch (MIDletStateChangeException e) {
-
// TODO Auto-generated catch block
-
e.printStackTrace();
-
}
-
-
}
-
}
-
-
}
@右击DemoHelloWorld -> Run As -> Emulated J2ME Midlet
发表于 @ 2008年01月15日 16:51:00|评论(loading...)|编辑