您的位置:首页 > 其它

J2ME入门程序--第一个HELLOWORLD手机程序

2009-10-13 17:06 465 查看
<!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;
mso-font-charset:2;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:0 268435456 0 0 -2147483648 0;}
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;
text-underline:single;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:1654017541;
mso-list-type:hybrid;
mso-list-template-ids:-2120340816 21917624 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-text:"/(%1)";
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-36.0pt;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
-->

主要是开发环境的配置和运行时的一点点注意事项:

第一:安装环境需要。

(1

JDK (
我用的是
jdk-1_6_0_12-windows-i586-p.exe)
高于这个亦可。
' E% _: `% ]$ M$ R! p. q# `

功能:开发
java
程序必备。

) s9 [4 z6 V# ~! B/ g9
ldev.chinamobile.com

5 E( ^1 D1 F4 ^ }# g
(2)WTK (Wireless Toolkit 2.5.2)
当前最新版本
2.5.2


. Z4 j# y1 |* ^, /

开发者社区论坛

功能:
Eclipse

j2me
调试设备,需要用到
WTK
中的设备。
dev.chinamobile.com0 W# W5 w3 `2 ^7 b

下载地址:
http://java.sun.com/products/sjwtoolkit/zh_download-2_5_2.html

说明:这个也是为了开发方便,就相当于一个应用平台,可以开发程序直接放到这里面运行是同样的效果。

2 z4 U6 c5 K, b t!
I I9 l& k

开发者社区论坛
"
u0 Q# m" [' O5 z$ A

(3)Eclipse
,任意新版本都可,我用的是
3.5
英文版。
开发者社区论坛
4
r0 k0 @- A5 l- j- z7 m

功能:开发
IDE
dev.chinamobile.com4
z9 ^. t+ O! J" L; V! T

下载地址:
http://www.eclipse.org/downloads ... e-SDK-3.5-win32.zip

中国移动开发者社区
! q, m, ~ A% W% b% T2
q7 W& D1 @! C

该版本为
Eclipse Classic 3.5.0 (162 MB)

版本
dev.chinamobile.com*
i( Y$ @5 Z5 F( {/ f0 C0 O$ E8 n

K* e5 G4 C( R5 [
(4)eclipseme
1.7.9

6 O. ?6 [# ~! T

中国移动开发者社区

Eclipse
中应对与
j2me
的插件,可以简单方便的完成
j2me
的开发。
. Z6 x9 U8 ?4 Y, N" _; P, p1 x

下载地址:
http://sourceforge.net/projects/eclipseme/files/

4 { ~* h3 ? k5 n*
S5 U1 a

点击其中的相应文件即可。

前面三个的安装一路下去就
OK
了,只有最后一个插件就在
Eclipse
当中安装就可以了。这也很简单。具体的安装如:
HELP
à

INSTALL NEW SOFTWARE
à

然后选择
eclipseme 1.7.9
文件就可以了。很简单吧,这里只有
JDK
需要配置环境变量就可以。

第二:配置
Eclipse


(1)

配置集成:
Window
à

preferences
à

有个
J2ME
,然后选中,
à

选第一项(
Device Management

à


import
à

路径就选择你的
WTK
的安装路径,
OK
了,

(2)

然后就是
NEW
一个
J2ME
工程了,网上一大堆。这个随便找都是,随便直接
new
都能够建立一个,直接就可以运行了。

(3)

程序见下:

(4)

然后就是运行
—>
点击
run
下拉列表
à

选择左面的
Wireless ToolKit Emulate
下面的要运行的工程,比如这里的
hello—>
主要是右面要选中
Midlet
按钮,然后选择你的
Hello
程序就可以了,哈哈,这里你输入一个

H
他就会出现的,
很简单吧,然后就有了,不会出现网上说的那些问题。

程序很简单,用
Eclipse
可以自动生成。其他开发工具也不复杂。

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
public class Hello extends MIDlet {
private Display display;
public Hello() {
display = Display.getDisplay(this);
}

public void startApp() {
TextBox t = new TextBox(
"First MIDP Programe", "Hello World!", 50,
TextField.ANY);
display.setCurrent(t);
}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: