程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> J2ME >> 在Eclipse下利用J2ME POLISH

在Eclipse下利用J2ME POLISH

編輯:J2ME

在Eclipse 下利用J2ME POLISH 這是一個簡略的幫助文檔,看完後你將學會polish的基礎用法,並用它構建你的J2ME工程。 Polish擁有著強盛的預編譯命令,用它可以很方便的往打包資源和分別代碼。 1.配置:第一步解壓縮最好放到根目錄下,無需安裝。第二步將xml的解析文件copy到工程目錄下。第三步在xml上單擊右鍵選擇-打開方法-ant構建。就是這麼簡略。 2.先容xml下面是一個例子,在這個XML下填寫jad,和資源的目錄。很簡略,信任大家都能看懂。<!-- This file controls the build process.                    --><!-- The most important target is the J2MEpolish-target,      --><!-- which controls for what devices the application should   --><!-- be created and so on.                                    --><!--                                                          --><!-- Important: when you have no Wireless Toolkit installed   --><!-- you need to define the "preverify"-attribute             --><!-- of the <build>-element of the J2ME Polish task.          --><!--                                                          --><!-- When you call Ant from the command-line, you can         --><!-- call "ant test J2MEpolish" to skip the obfuscation       --><!-- and to build the example for fewer handsets.             -->

<!-- The default target builds and obfuscates the example.    --><!--                                                          --><!-- The full documentation can be found at                   --><!-- http://www.J2MEpolish.org                                --><!--                                                          --><!-- Have fun!                                                --><project    name="SC"    default="J2MEpolish"> <!-- The wtk.home property should point to the directory      --><!-- containing the Wireless Toolkit.                         --><propertyname="wtk.home"value="C:\WTK22"/>

<!-- The polish.home property should point to the directory   --><!-- containing the J2ME Polish installation.                 --><propertyname="polish.home"value="C:\J2ME-Polish"/> <!-- The sIEmens.home, nokia.home and motorola.home-          --><!-- propertIEs can be necessary when their emulators         --><!-- should be started.                                       --><!-- The directory which contains the SIEmens-SMTK    <property name="siemens.home" value="C:\sIEmens" />--><!-- The directory which contains the 諾基亞-emulators    <property name="nokia.home" value="C:\諾基亞" />--><!-- The path to the Sony-EriCSSon SDK    <property name="sony-ericsson.home" value="C:\SonyEriCSSon\J2ME_SDK" />--><!-- The directory which contains the Motorola-emulators    <property name="motorola.home" value="C:\Program Files\Motorola\SDK v4.3 for J2ME" />--> <!-- Definition of the J2ME Polish task:                      --><taskdefname="J2MEpolish"

  classname="de.enough.polish.ant.PolishTask"    classpath="${polish.home}/import/enough-J2MEpolish-build.jar:${polish.home}/import/jdom.jar:${polish.home}/import/proguard.jar:${polish.home}/yguard-lib.jar:${wtk.home}/wtklib/kenv.zip"/> <targetname="init">  <propertyname="test"value="false"/>    <propertyname="dir.work"value="build"/></target> <targetname="clean"       description="allows a clean build. You should call [ant clean] whenever you made changes to devices.xml, vendors.xml or groups.XML">    <deletedir="build"/>    <deletedir="dist"/></target> 

<!-- In this target the J2ME Polish task is used.             --><!-- It has 3 sections:                                       --><!--    1. The info-section defines some general information --><!--    2. The deviceRequirements-section chooses the devices --><!--       for which the application is optimized.            --><!--    3. The build-section controls the actual build        --><!--       process.                                           --><targetname="J2MEpolish"        depends="init"        description="This is the controller for the J2ME build process."        >    <J2MEpolish>        <!-- general settings, these settings basically form the JAD-attributes. -->        <!-- Have a look at the <jad>-section for setting specialised attributes.             You can also define localized attributes in the resources/messages.txt files -->

   <info            license="GPL"            name="驅魔Q傳"            version="1.0"            description="單機版;諾基亞_N${polish.name};動作類"            vendorName="創藝和弦"            icon="/icon.png"            jarName="ExorcismSWord_NOK_N${polish.name}.jar"        />        <deviceRequirementsunless="test">            <or>            <requirementname="IdentifIEr"

value="諾基亞/7610"/>            </or>        </deviceRequirements>        <build            symbols=""            fullscreen="yes"            usePolishGui="false"            workDir="${dir.work}">             <midletclass="GhostMidlet"name="驅魔Q傳"/>            <variablesincludeAntPropertIEs="true">                <variablename="update-url"value=http://www.enough.de/update

/>                <variablename="title"value="cc"/>            </variables>             <resourcesdir="res"excludes="">                <filesetdir="res/"if="polish.identifIEr == 諾基亞/7610"/>            </resources>             <obfuscatorname="ProGuard"useDefaultPackage="true"unless="test">            </obfuscator>                 <jad>                          

<attributename="MicroEdition-Configuration"value="CLDC-1.0"/>                           <attributename="MicroEdition-Profile"value="MIDP-1.0"/>                          <attributename="Media-Price"value="單次下載8元"/>                 </jad>        </build>    </J2MEpolish></target> </project> 3.Polish語法簡介:幾個例子,關於不同屏幕大小設置變量坐標。    //#if (polish.ScreenWidth == 240)    byteoffextX=20;    inttitleNameX=25+offextX

;    inttitleNameY=43+20;    intnameOffestX=33+4;    intnameOffestY=33;    intnumOffestX=23;    intnumOffestY=42+4;    intnumAllY=-5;     bytenameTranY=1;     intmidleMuX=-20+offextX;    intmidleMuY=-40+30+10;     intyoungManX=-70+offextX;

  intyoungManY=-40+90+10;     integgX=-20;    integgY=-37+90+10;     intbigEggX;    intbigEggY=13-12;     //#else (polish.ScreenHeight == 220)    //# int titleNameX=25;    //#     int titleNameY=43;    //#     byte nameOffestX=33;    //#     byte nameOffestY=33;    //#     byte numOffestX=23;    //#     byte numOffestY=42;    //#     byte numAllY=-5;     //#     byte nameTranY=1;     //#     int midleMuX=-20;

 //#     int midleMuY=-40;     //#     int youngManX=-70;    //#     int youngManY=-40;     //#     int eggX=-20;    //#     int eggY=-37;     //# int bigEggX;    //# int bigEggY=13;    //#endif 不同按鍵。    //#if (polish.Vendor == Sony-EriCSSon) || (polish.Vendor == Samsung) || (polish.Vendor == 諾基亞)    finalstaticpublicintisLeftKey=-6;    finalstaticpublicintisRightKey=-7;     //#elif (polish.Vendor == Motorola)     //# final static public int isLeftKey=-21;    //# final static public int isRightKey=-22;

//#endif   4. build失敗的可能原因:Jdk的版本1.42的可以,高版本的會出錯。(可能和polish的版本有關)XML的修正的參數有誤,如midlet的名字,是否存在的資源文件夾,wtk,polish的路徑。Polish語法有錯,這個一般會在build失敗的把持台下有標記。另外混雜包的路徑也要設置准確 由於太忙的原因,基礎上我沒有寫什麼東西,慢慢我會把這個帖子完善的。

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved