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

  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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值