您的位置:首页 > 编程语言 > Java开发

使用eclipse搭建j2me手机开发环境

2010-12-02 13:15 525 查看
使用eclipse搭建j2me手机开发环境

1 下载 eclipse3.1 / jwtk2.2 / eclipseme1.2.3

    eclipse3.1的下载地址:
http://www.eclipse.org/

    jwtk2.2    的下载地址:http://java.sun.com/j2me/download.html

    eclipseme1.2.3的下载地址:http://eclipseme.org/

2  安装 eclipse 到 d:/eclipse3.1 ;

           jwtk2.2 到 d:/jwtk2.2 (为jwtk2.2打patch) 

           eclipseme1.2.3 到 d:/eclipseme1.2.3

3  配置eclipseme到eclipse

< 1>启动 eclipse->点击 help ->点击 software updates ->点击  find and install ->选择 search for new features to install->点击  next ->点击 new archived site -> 选择 eclipseme1.2.3.zip - > 点击  finish -> 重新启动eclipse

<2>点击 windows ->选择 preference  ->选择 J2ME ->选择 platform component ->点击wirelessToolkits->点击右键  选择 add wirelessKit ->选择 jwtk2.2的安装目录->点击 finish

<3>开启测试项目 ,重新启动eclipse,file ->new ->project ->j2me ->j2me midlet suite ->命名项目名称为testJ2me

<4>验证环境搭建,在项目中编写一个名为HelloWorldMIDlet 的java程序,源码如下:

package com.agile.j2me.core;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.Display;

public class HelloWorldMIDlet extends MIDlet {
private TextBox tBox ; 
public HelloWorldMIDlet() {
  super();
  tBox = new TextBox("测试程序","hellWorld",20,0);
  // TODO Auto-generated constructor stub
}

protected void startApp() throws MIDletStateChangeException {
  // TODO Auto-generated method stub
  Display.getDisplay(this).setCurrent(tBox);
}

protected void pauseApp() {
  // TODO Auto-generated method stub

}

protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
  // TODO Auto-generated method stub

}

}

<5>运行 -> 选择run as -> emulated j2me midlet.

<6>手机模拟界面出现helloworld字样,配置成功.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: