- 使用的軟體如下:
- Java JDK:j2sdk1.4.2_08
- Eclipse:eclipse-SDK-3.1.1-win32.zip
- Eclipse J2ME:eclipseme 1.2.3(解壓縮至eclipse安裝目錄下)
- J2ME Wireless Toolkit:J2ME Wireless Toolkit 2.1_01
- Sony Ericsson J2ME SDK:Sony Ericsson SDK 2.2.3
(各大手機廠牌SDK下載點)
- eclipse的設定如下:
- 執行eclipse
- File --> Imoprt -->Extenal Plug-ins and Fragments --> 點Next直到Selection,把eclipseMe加進去,再按finished -->OK
- Windows --> Preference -->J2ME --> Platform Components -->在右邊Wireless Toolkits上按右鍵 --> 加入WirelessTookit --> 選要加入的SDK,使用J2ME Wireless Toolkit路徑為:c:\wtk21,若使用其它廠牌專用的SDK,可以在此設定,以SE T630為例:C:\SonyEricsson\J2ME_SDK\PC_Emulation\WTK1
- 測試:
- 執行eclipse,點選 File --> New --> Other -->選MIDlet Suit --> 打個名字 --> OK!!
- 在剛剛作出來的MIDletSuit再如上加入一個 MIDlet,File --> New --> Other -->選MIDlet --> 打個名字 --> OK!!
- Run --> Wireless Toolkit Emulator --> Emulation --> 1.Platform Definition=SonyEricsson_T630 Platform --> 2.Device=SonyEricsson_T630 --> OK!!
大功告成,接下來就會看到WTK的手機模擬器跑出來了
安裝參考網址
接著呢~就是來寫第一個J2ME程式!
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloMIDlet extends MIDlet {
Display display;
Form f;
public HelloMIDlet() {
display = Display.getDisplay(this);
f = new Form("HelloMIDlet");
f.append("Hi~~Everybody!!");
display.setCurrent(f);
}
protected void startApp() {
}
protected void pauseApp() {
}
protected void destroyApp(boolean arg0) {
}
}
程式參考網址