J2ME Polish 核心優勢在於 Build 自動化(Ant 擴展)、裝置資料庫 (230+ 裝置參數) 與 預處理器 實現多版本自動打包。
安裝 J2ME Polish 2.0-RC4 時勾選 Eclipse Integration (Mepose),自動安裝插件。專案建立後含 build.xml、src/、resource/。右鍵 build.xml → Run As → Ant Build 即可建置。
<midlet>:定義 MIDlet 屬性,生成 JAD/Manifest<deviceRequirements>:指定目標裝置 (如 Nokia/6600,Motorola/E680),關聯裝置資料庫<build>:設定主類別、第三方庫、usePolishGui (預設 true,未用 Polish UI 時設 false 減小 JAR)定義裝置識別碼、群組繼承 (Series60 → Nokia-UI)、功能標記 (hasCamera)、能力參數 (HeapSize、ScreenSize、MaxJarSize、Bugs 等)。
public class MyCanvas
//#if polish.api.nokia-ui
//# extends com.nokia.mid.ui.FullCanvas
//#else
extends Canvas
//#endif
{
public MyCanvas() {
//#ifndef polish.api.nokia-ui
//# setFullScreenMode(true);
//#endif
//#ifdef polish.ScreenSize:defined
//# String screenSize = "${polish.ScreenSize}";
//#else
String screenSize = "128*128";
//#endif
//#ifdef polish.HeapSize:defined
//# int heapSize = ${bytes(polish.HeapSize)};
//#else
int heapSize = 1000;
//#endif
}
public void drawClip(Graphics g, int x, int y, Image img,
int clipX, int clipY, int clipW, int clipH, int mode) {
//#if polish.api.nokia-ui
//# ... Nokia 切片繪圖 ...
//#else
... // MIDP 2.0 標準繪圖 ...
//#endif
}
}
建置後在 build/real/ 產生各裝置版本原始碼。
polish_home/import/ 函式庫,升級不便