服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

jcreater+motoj2sdk的配置与使用心得


   假设安装路径如下:

     jcreator d:/program files/xinox software/jcreator le

   motoj2sdk d:/motoj2sdk

   jdk d:/jdk1.3.1

   注意:要先击活模拟环境,运行d:/motoj2sdk/generic/scripts/runconstructor.bat

   选择手机型号,选择语言,选择normal, 再"创建"。

   启动jcreater之后我的配置如下:

   第一步

   选择 configure->options->jdk profiles

   注意:一定新建 profile and select “d:/jdk1.3.1”

   将名字改为“j2me 388”

   add classes path “d:/motoj2sdk/lib”

   add documentation path “d:/motoj2sdk/docs”

   分别将后加的两行移到最上方.

   第二步

   选择 configure->options->jdk tools

   选择complier 选中 and edit it.

   将 parameters 变为 -classpath d:/motoj2sdk/lib $[javafiles]
   第三步

   选择 configure->options->tools

   点击“new”选择 dos command

   名字为“preverifier”

   将 arguments 换为 d:/motoj2sdk/bin/preverifier.exe -classpath "d:/motoj2sdk/lib" -d . .

   将 initial directory 变为 “$[prjdir]”

   第4步

   按上面的方法在new一个 dos command

   名字:“run emulator”

   将 arguments 换成 “java -djava.library.path=d:/motoj2sdk/lib -classpath "d:/motoj2sdk/bin/emulator.jar";"d:/motoj2sdk/configtool.jar" com.mot.tools.j2me.emulator.emulator -classpath$[prjdir];"d:/motoj2sdk/lib" -devicefile d:/motoj2sdk/bin/resources/device.props javax.microedition.midlet.appmanager $[curclass] -jsa 1 1”

   将 initial directory 换成 “d:/motoj2sdk/bin”

   ok!编辑工具配置完毕!

   新建一个工程――选择empty project

   再取一个名字 比如:test

   则jcreater自动在你的工作目录中生成目录test

   再new一个file选择java file

   写好你的原代码,保存 如:test.java

   在project中 选add file

   然后选中你刚才的test.java

   注意:不要有package ;

   编译――》tools中的preverifier进行预先审核――》tools中的run emulator进行模拟

   test.java 的例子:功能是捕捉键盘输入的ascii吗。

   import javax.microedition.lcdui.*;

   import javax.microedition.midlet.*;

   public class test extends midlet implements commandlistener {;

   /**

   * the screen for this midlet

   */
   private keyeventsdemocanvas mycanvas;

   /**

   * reference to current display

   */

   private display mydisplay;

   /**

   * command to make sure soft key is not a key event

   */

   private command okcommand = new command("ok", command.ok, 1);

   test() {;

   mydisplay = display.getdisplay(this);

   mycanvas = new keyeventsdemocanvas();

   mycanvas.addcommand(okcommand);

   mycanvas.setcommandlistener(this);

   };
/**

   * do nothing if a command is fired
   */

   public void commandaction(command c, displayable s) {;

   };

   /**

   * start the midlet

   */

   protected void startapp() throws midletstatechangeexception {;

   mydisplay.setcurrent(mycanvas);

   };

   /**

   * pause the midlet

   */

   protected void pauseapp() {;

   };

   /**

   * called by the framework before the application is unloaded

   */
   protected void destroyapp(boolean unconditional) {;

   };

   /**

   * the screen for this application

   */

   class keyeventsdemocanvas extends canvas {;

   /**

   * background color (i.e. the color of the screen)

   */

   public final int background_color = 0xffffff; // white

   /**

   * foreground color (i.e. the color of the rectangles)

   */

   public final int foreground_color = 0x000000; // black

   /**

   * last key that was pressed
   */

   private int lastkey;

   /**

   * paint the screen

   */

   public void paint(graphics g) {;

   /*

   * clear the screen

   */

   g.setcolor(background_color);

   g.fillrect(0, 0, getwidth(), getheight());

   /*

   * paint the message

   */

   g.setcolor(foreground_color);

   g.drawstring("press a key!", 0, 0, graphics.top | graphics.left);

   if (lastkey != 0) {;

   g.drawstring("key code: " + lastkey, 0, g.getfont().getheight(),

   graphics.top | graphics.left);

   try {;

   g.drawstring("action: " + getgameaction(lastkey), 0,

   2 * g.getfont().getheight(),

   graphics.top | graphics.left);

   g.drawstring("key name: " + getkeyname(lastkey), 0,

   3 * g.getfont().getheight(),

   graphics.top | graphics.left);

   }; catch (exception e) {;

   // ignore since alphabet keys will throw this exception

   };

   };

   };
   /**

   * handle key press

   */

   public void keypressed(int keycode) {;

   lastkey = keycode;

   repaint();

   };

   /**

   * demonstrate keyrepeated events

   */

   public void keyrepeated(int keycode) {;

   system.out.println("key repeated " + keycode);

   };

   };

   };
(中国java手机网)

扫描关注微信公众号