Chinaunix首页 | 论坛 | 博客
  • 博客访问: 460519
  • 博文数量: 155
  • 博客积分: 2954
  • 博客等级: 少校
  • 技术积分: 1000
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-12 22:00
文章分类

全部博文(155)

文章存档

2014年(2)

2013年(5)

2012年(10)

2011年(33)

2010年(105)

我的朋友

分类: Java

2010-05-11 12:59:26

Polish()是一套开发J2ME程序的工具集.
Polish自带设备库,可根据配置生成基于不同设备和语言的J2ME应用程序,通过统一的API从而隔离了不同设备之间对API支持的差异性.
通过ant方式对源代码进行预处理,构建,打包,模拟,调试.用户界面的更改可通过设置CSS进行调整.另外,polish还附带
 
polish的配置文件:
 global.properties 记录相关工具的路径,如wtk等,因为相关的device可能需要这些工具
 devices.xml  设备类型配置文件,指定命名的设备及具支持的特征
 
polish自带的sample的build.xml:
 
1.运行模拟器时可通过device属性来指定设备(test时使用):ant -Ddevice=Generic/midp2 emulator
 
2.build各设备支持的jad和jar包:ant 或 ant j2mepolish
 
3.测试应用(skip the obfuscation step): ant -Ddevice=Generic/midp2 test j2mepolish 等同于 ant -Ddevice=Generic/midp2 emulator
 
4.debug(skip the obfuscation step):ant -Ddevice=Generic/midp2 debug 等同于 ant -Ddevice=Generic/midp2 enableDebug test j2mepolish
 
Q&A:
 
□如何安装插件? 2008-1-7 11:45:52
polish的eclipse插件为mepose,最新版本的polish中已经带了该插件,安装的时候即可附带安装.该插件安装后可通过向导创建polish应用,并自动生成build.xml等相关配置.同时可直接对midlet运行polish(通过context菜单)

--------------------------------------------------------------------------------

□为什么运行时会提示ClassNotFoundException?
通过在build.xml中指定midlet:


 
这样通过ant build出来的jad中的midlet的名称为上面配置中"name"指定的名称,直接通过class运行时要注意,不然会提示:
Running with locale: Chinese_People's Republic of China.936
Running in the identified_third_party security domain
java.lang.ClassNotFoundException: com/sily/polish/Test
        at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
        at com.sun.midp.midlet.Scheduler.schedule(+52)
        at com.sun.midp.main.Main.runLocalClass(+28)
        at com.sun.midp.main.Main.main(+80)
 
而通过方式指定midlet而生成的jad文件正好有上面的错误,所以导致通过jad无法正确运行,修改为正确的即可.产生错误的原因可能是因为polish在调用preguard的时候,对类名转换了,但生成jad的时候没正确转换导致的.
 

--------------------------------------------------------------------------------
□如何设置locale? 2008-1-4 16:1:51
设置locale:

--------------------------------------------------------------------------------
□import改为lib的问题 2008-1-4 12:56:37
升级mepose到最新的0.72版本则没有之前碰到import改为lib的问题了.
mepose目前的版本对eclipse支持不是很好,有一些问题,详见polish的文档.

--------------------------------------------------------------------------------

 
□如何指定J2ME-Polish?
 
要使build.xml正确运行,必须指定正确的polish目录:

--------------------------------------------------------------------------------

□为何通过mepose生成的build.xml提示包路径错误?
 
通过eclipse的插件mepose0.5版生成的build.xml中需要修改如下部分才能正确运行:
 
   classname="de.enough.polish.ant.PolishTask"
  classpath="${polish.home}/lib/enough-j2mepolish-build.jar:${polish.home}/lib/jdom.jar"
 />
 
原错误的路径为:${polish.home}/import/...

--------------------------------------------------------------------------------

□2008-1-4 9:59:40 用eclipse生成的build.xml为什么有问题?

我在polish的文档中看到:
In J2ME Polish 2.0 the enough-j2mepolish-build.jar moved from the import to the lib folder, so any task definitions within build.xml scripts have to be changed

还有,build.xml中info元素不支持license属性:
License Key
In J2ME Polish 1.x the license attribute of the element described the used J2ME Polish license. This element is not supported anymore and is ignored. Existing J2ME Polish 1.x customers can upgrade to 2.x, please inquire for details by sending a query to j2mepolish(at)enough(dot)de.

 
这是由于eclipse的插件mepose为0.55版本的,是基于polish 1.x的,而我们用的是polish 2.0的


--------------------------------------------------------------------------------

作者简介:
施祖阳,网名sylilzy。
2002年起从事软件开发工作,主要研究JAVA、Linux及相关技术。
http://blog.sina.com.cn/sylilzy
你可通过sylilzy@163.com与作者联系。
 
参考资料:
/docs/tutorial.html
http://blog.csdn.net/zjsjava/archive/2007/11/28/1905896.aspx

阅读(811) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~