日期:2014-05-20  浏览次数:20696 次

j2me 环境搭建

用Eclipse和WTK搭建J2ME开发环境

关键字: j2me

所用工具:
JDK1.5.0_9
Eclipse-SDK-3.1-win32.zip
Eclipseme.feature_1.0.0_site.zip
sun_java_wireless_toolkit-2_2-beta-windows.exe

操作系统:window_xp_sp2

安装步骤:
1、安装JDK1.5.0_9,注意设置好系统环境变量(Java_Home为Jdk安装目录,Path为Jdk中bin目录路径,ClassPath设置为.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar);
2、解压安装Eclipse-SDK-3.1-win32.zip;
3、安装sun_java_wireless_toolkit-2_2-beta-windows.exe;
4、启动Eclipse,通过菜单Help->Software Updates->Find and Install...->Search for new feathers to install->New achieved sites选项,安装Eclipseme.feature_1.0.0_site.zip;
5、通过菜单Window->Preferences的J2ME选项中add wireless toolkit整合eclipse和wtk,到此安装已经完成,可以通过建立新工程来进行测试。

Hello.java测试代码:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Hello extends MIDlet
{
??? private Display display;?
??? public Hello()
??? {
??? ??? display = Display.getDisplay(this);
??? }
?? ?public void startApp()
??? {
??? ???? Form f = new Form("Hello world的测试");
?????????f.append("hello world!");
??????? display.setCurrent(f);
??? }
?? ?public void pauseApp()
??? {}
??? public void destroyApp(boolean unconditional)
??? {}
}