返回> 网站首页 

J2ME开发环境 – 系统环境检测程序

yoours2011-08-27 17:07:14 阅读 1187

简介一边听听音乐,一边写写文章。

  1. J2ME环境安装

    下载并安装如下程序,并按照以下顺序安装:

    可在如下网址寻找

    http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javame-419430.html

j2sdk-1_4_2_07-windows-i586-p.exe

j2me_wireless_toolkit-2_2-ml-windows.exe

j2me_wireless_toolkit-2_2-update_1-ml-windows.zip

  1. 创建自己的J2ME程序

    启动开始菜单中 J2ME Wireless Toolkit 2.2 –> KToolbar

    1. 点击新建项目 -> 输入项目名字以及MiDlet类名为HelloWord。
    2. 打开 C:\WTK22\apps\HelloWord\src目录,创建Hello.java文件
    3. 输入J2ME代码:

      import javax.microedition.midlet.*;

      import javax.microedition.lcdui.*;

       

      public class Hello extends MIDlet implements CommandListener

      {

      Display display;

      Form showForm;

      Command button;

      Font myFont;

       

      public Hello() {

              showForm = new Form("J2ME系统检测信息");

      }

       

      protected void destroyApp(boolean unconditional) {

      }

       

      protected void pauseApp() {

      }

       

      protected void startApp() {

      display = Display.getDisplay(this);

              myFont = Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_PLAIN,Font.SIZE_SMALL);

       

      // 系统信息

      StringItem str = new StringItem("\r\n", "平台名称:" + System.getProperty("microedition.platform"), Item.PLAIN);str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "MIDP版本:" + System.getProperty("microedition.profiles"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "CLDC或CDC版本:" + System.getProperty("microedition.configuration"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "默认的系统编码:" + System.getProperty("microedition.encoding"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "默认的区域设置:" + System.getProperty("microedition.locale"));str.setFont(myFont);showForm.append(str);

       

      // MMAPI相关

      str = new StringItem("\r\n", "MMAPI的版本:" + System.getProperty("microedition.media.version"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "支持混音:" + System.getProperty("supports.mixing"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "支持音频捕获:" + System.getProperty("supports.audio.capture"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "支持视频捕获:" + System.getProperty("supports.video.capture"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "支持录音:" + System.getProperty("supports.recording"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "音频编码格式:" + System.getProperty("audio.encodings"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "拍摄图片的编码格式:" + System.getProperty("video.snapshot.encodings"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "支持的流媒体格式:" + System.getProperty("streamable.contents"));str.setFont(myFont);showForm.append(str);


       //WMA相关

      str = new StringItem("\r\n", "SMS的服务中心:" + System.getProperty("wireless.messaging.sms.smsc"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "MMS的服务中心:" + System.getProperty("wireless.messaging.mms.mmsc"));str.setFont(myFont);showForm.append(str);

       

      // 其他

      str = new StringItem("\r\n", "Mobile 3D的版本:" + System.getProperty("microedition.m3g.version"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "蓝牙API的版本:" + System.getProperty("bluetooth.api.version"));str.setFont(myFont);showForm.append(str);

       

      str = new StringItem("\r\n", "FileConnection的版本:" + System.getProperty("microedition.io.file.FileConnection.version"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "PIM的版本:" + System.getProperty("microedition.pim.version"));str.setFont(myFont);showForm.append(str);

       

      str = new StringItem("\r\n", "file.separator:" + System.getProperty("file.separator"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "microedition.commports:" + System.getProperty("microedition.commports"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "microedition.hostname:" + System.getProperty("microedition.hostname"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "microedition.smartcardslots:" + System.getProperty("microedition.smartcardslots"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "microedition.location.version:" + System.getProperty("microedition.location.version"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "microedition.sip.version:" + System.getProperty("microedition.sip.version"));str.setFont(myFont);showForm.append(str);

      str = new StringItem("\r\n", "microedition.jtwi.version:" + System.getProperty("microedition.jtwi.version"));str.setFont(myFont);showForm.append(str);

       

       // 定义一个按钮

       button = new Command("Exit", Command.ITEM, 10);

       // 追加到form中

       showForm.addCommand(button);

       // 注册监听器

       showForm.setCommandListener(this);

      display.setCurrent(showForm);

      }

       

      // 监听处理

          public void commandAction(Command c, Displayable d)

          {

             if (c == button)

              {

                  notifyDestroyed();

                  destroyApp(true);

              }

          }

      }

 

  1. 点击生成按钮,编译java文件。
  2. 点击项目->包->产生包,产生jar文件。

将生成的jar文件考入手机中,安装运行。即可显示出系统所支持的信息。

微信小程序扫码登陆

文章评论

1187人参与,0条评论