在Eclipse 下应用J2ME POLISH

 

在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.                         -->
<property name= "wtk.home" value= "C:/WTK22" />
<!-- The polish.home property should point to the directory   -->
<!-- containing the J2ME Polish installation.                 -->
<property name= "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 Nokia-emulators
    <property name="nokia.home" value="C:/Nokia" />
-->
<!-- 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:                      -->
<taskdef name= "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" />
 
<target name= "init" >
   <property name= "test" value= "false" />
    <property name= "dir.work" value= "build" />
</target>
 
<target name= "clean"
       description= "allows a clean build. You should call [ant clean] whenever you made changes to devices.xml, vendors.xml or groups.xml" >
    <delete dir= "build" />
    <delete dir= "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.                                           -->
<target name= "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= " 单机版;Nokia_N${polish.name};动作类"
            vendorName= " 创艺和弦"
            icon= "/icon.png"
            jarName= "ExorcismSword_NOK_N${polish.name}.jar"
        />
        <deviceRequirements unless= "test" >
            <or>
            <requirement name= "Identifier" value= "Nokia/7610" />
            </or>
        </deviceRequirements>
        <build
            symbols= ""
            fullscreen= "yes"
            usePolishGui= "false"
            workDir= "${dir.work}" >
 
            <midlet class= "GhostMidlet" name= " 驱魔Q传" />
            <variables includeAntProperties= "true" >
                <variable name= "update-url" value= "http://www.enough.de/update" />
                <variable name= "title" value= "cc" />
            </variables>
 
            <resources dir= "res" excludes= "" >
                <fileset dir= "res/" if= "polish.identifier == Nokia/7610" />
            </resources>
 
            <obfuscator name= "ProGuard" useDefaultPackage= "true" unless= "test" >
            </obfuscator>
                  <jad>
                           <attribute name= "MicroEdition-Configuration" value= "CLDC-1.0" />
                           <attribute name= "MicroEdition-Profile" value= "MIDP-1.0" />
                          <attribute name= "Media-Price" value= " 单次下载8元" />
                  </jad>
        </build>
    </j2mepolish>
</target>
 
</project>
 
3.Polish语法简介:
几个例子,
关于不同屏幕大小设置变量坐标。
    //#if (polish.ScreenWidth == 240)
    byte offextX =20;
    int titleNameX =25+ offextX ;
    int titleNameY =43+20;
    int nameOffestX =33+4;
    int nameOffestY =33;
    int numOffestX =23;
    int numOffestY =42+4;
    int numAllY =-5;
 
    byte nameTranY =1;
 
    int midleMuX =-20+ offextX ;
    int midleMuY =-40+30+10;
 
    int youngManX =-70+ offextX ;
    int youngManY =-40+90+10;
 
    int eggX =-20;
    int eggY =-37+90+10;
 
    int bigEggX ;
    int bigEggY =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 == Nokia)
    final static public int isLeftKey =-6;
    final static public int isRightKey =-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失败的控制台下有标记。
另外混淆包的路径也要设置正确
 
由于太忙的原因,基本上我没有写什么东西,慢慢我会把这个帖子完善的。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值