当前位置: 首页 > 工具软件 > EclipseME > 使用案例 >

配置J2ME开发环境 Eclipse、eclipseME、WTK

卫博学
2023-12-01
  1. 下载ECLIPSE

http://www.eclipse.org/downloads/

  1. 下载WTK

http://java.sun.com/products/sjwtoolkit/

  1. 下载 eclipseME

http://eclipseme.org/

  1. 给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;

importjavax.microedition.midlet.MIDletStateChangeException;

 

public class DemoHelloWorld extends MIDlet implementsCommandListener {

private Display display;

private TextBox textBox;

private Command quitCommand;

public DemoHelloWorld() {

// TODO Auto-generated constructor stub

}

 protected void destroyApp(boolean arg0) throwsMIDletStateChangeException {

// TODO Auto-generated method stub

 }

 protected void pauseApp() {

// TODO Auto-generated method stub

 }

 protected void startApp() throwsMIDletStateChangeException {

// TODO Auto-generated method stub

display=Display.getDisplay(this);

quitCommand= newCommand("Quit",Command.SCREEN,1);

textBox = new TextBox("Goodbye World","Mysecond MIDlet",500,0);

textBox.addCommand(quitCommand);

textBox.setCommandListener(this);

display.setCurrent(textBox);

 }

 public void commandAction(Command choice, Displayabledisplayable){

if(choice==quitCommand){

try {

destroyApp(false);

notifyDestroyed();

} catch (MIDletStateChangeException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

}


@右击DemoHelloWorld -> Run As -> Emulated J2ME Midlet

 类似资料: