站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2ME 专题j2me环境下开发HELLOWORLD程序-汉土网络

j2me环境下开发HELLOWORLD程序-汉土网络

摘要: j2me环境下开发HELLOWORLD程序-汉土网络
<tr> <td> <tr> <td colspan="3">IT技术资料馆|编程语言|java系列|J2ME资料|j2me环境下开发HELLOWORLD程序</td> </tr> <tr> <td height="38" colspan="3" align="center">

j2me环境下开发HELLOWORLD程序

</td> </tr> <tr> <td colspan="3" align="center"></td> </tr> <tr> <td colspan="3" class="text">在使用Motorola SDK之前必须安装JDK,Standard Edition。请从http://java.sun.com/products/jdk 下载JDK,并按照Sun的指导安装到PC中。

3.安装Motorola SDK

安装之前请先卸载以前版本的Motorola SDK:
1. 选择"开始à设置à控制板"
2. 选择"添加/删除程序"
3. 查找到"Motorola SDK Components for the J2ME Platform"
4. 点击"卸载"
5. 用资源管理器删除"MotoSDK"目录

安装SDK:
1. 运行"Motorola_SDK.exe"
2. 按照提示安装程序
注意:安装程序需要口令,请向Motorola公司索取。

4.编写第一个程序

在目录"MotoSDKdemomidletscommotj2memidletsutorials"中,用编辑器创建文件"HelloWorld.java"。

/*
* HelloWorld.java
*
* June 27, 2000
*
* ? Copyright 2000 Motorola, Inc. All Rights Reserved.
* This notice does not imply publication.
*/

package com.mot.j2me.midlets.tutorials;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

/**
* A simple Hello World midlet
*
* @see MIDlet
*/

public class HelloWorld extends MIDlet {
/**
* Main application screen
*/

private Form mainScreen;
/**
* A reference to the Display
*/

private Display myDisplay;
/**
* Creates a screen for our midlet
*/

HelloWorld() {
myDisplay = Display.getDisplay(this);
mainScreen = new Form("Hello World");
/*
* Create a string item
*/
StringItem strItem = new StringItem("Hello", "This is a J2ME MIDlet.");
mainScreen.append(strItem);
}

/**
* Start the MIDlet
*/
public void startApp() throws MIDletStateChangeException {
myDisplay.setCurrent(mainScreen);
}

/**
* Pause the MIDlet
*/
public void pauseApp() {
}
J2ME开发步骤



/**
* Called by the framework before the application is unloaded
*/
public void destroyApp(boolean unconditional) {
}

}

5.编译

编译"HelloWord"
1.在命令行窗口中,进入目录"MotoSDKdemomidlets"
2.输入"compileAll commotj2memidletsutorialsHelloWorld.java"

6.运行

运行"HelloWord"
1.在命令行窗口中,进入目录"MotoSDKscripts"
2.输入"runEmul com.mot.j2me.midlets.tutorials.HelloWorld" </td> </tr> <tr>
↑返回目录
前一篇: J2ME简介-汉土网络
后一篇: J2ME程序开发环境配置的一个简单例子-汉土网络