需要:

jdk,wtk就不用说了.

下载j2mepolish :http://www.j2mepolish.org/downloads/j2mepolish-1.2.4.html#download

直接双击jar文件(java -jar j2mepolish-1.2.4.jar)根据向导安装即可,很简单.

在eclipse中运行samples里面的menu例子.

拷贝 ${polish.home}/samepse/menu到eclipse的工作目录.

然后建立一个java工程名为 menu (会自动导入拷过来的menu里面的src,res等等)

直接ant运行build脚本即可生成jar,jad文件(会发现有很多版本,不同语言,不同平台,不同midp版本的)

要配置生成哪些版本,或者平台的jar,jad,可以在build.xml里面配置,如下位置:

语言(默认有德文和英文)可以在如下位置配置:(我把德文改称了中文)


  dir="resources"
  defaultexcludes="yes"
  excludes="readme.txt"
  >
 

注意,如果配置了一个cn的话,要在resources里面添加一个messages_cn.txt

内容可以如下:

#######################################
#                         #
#   This file contains translations   #
#   of the application.           #
#   Key and Value are separated     #
#   by the equals-sign "=".       #
#                         #
#######################################

# You can also define localized preprocessing variables here, by starting the
# definition with "var:". Variables defined here will override the ones defined
# in the -section of your build.xml.
# Variables starting with "polish." or "MIDlet-" don't need to start with "var:"
# by the way.
var:MyExampleVariable=你好,midlet
var:GameName=测试

# Setting J2ME Polish variables:
polish.command.ok=确认
polish.command.cancel=取消
polish.command.select=选择
polish.command.options=选项

# It's also possible to set MIDlet-attributes for your JAD- and MANIFEST-files here.
# If you like you can start them with "var:" as well, but it is not needed.
# Again MIDlet-attributes defined override the one defined in the -
# and -sections of your build.xml
MIDlet-Description=中文哦
MIDlet-Name=J2ME Polish Beispiel
MIDlet-Delete-Confirm=J2ME Polish

# Setting appplication specific translations:

cmd.StartGame=${GameName} 开始
cmd.Quit=退出
cmd.ShowLog=log 显示

menu.StartGame=${GameName} 开始!
menu.LoadGame=${GameName} 读取
menu.Highscore=最高分
menu.Quit=退出
#menu.go=出发

messages.welcome=欢迎阿, {0}!!!

=========================================

这个时候在dist目录下生成了中文的不同平台和midp版本的jad,jar文件

用模拟器运行即可看到效果

如果要在ant的时候就打开模拟器运行,修改一下build.xml的如下地方:


  //改为true

配置模拟器的地方:(不需要修改,我修改是不想看到内存和网络监视的那些东西)


  wait="true"
  trace="class"
  securityDomain="trusted"
  enableProfiler="false"   //默认true的,我改称了false
  enableMemoryMonitor="false" //默认true的,我改称了false

  enableNetworkMonitor="false" //默认true的,我改称了false

  if="test"
  >