技术开发 频道

J2ME打包解决移动平台api问题

  【IT168 技术文档】提交给移动上线的kjava游戏,如果直接用jb打包会遇到平台api 问题。

  现在我们可以用ant打包来解决移动平台api问题。具体方法如下:

  1.下载antenna-bin-0.9.13.jar,apache-ant-1.6.2

  2.把antenna-bin-0.9.13.jar放到apache-ant-1.6.2\lib下,

  3.把nokiaui.jar放到apache-ant-1.6.2\lib下,

  4.把gx.jar放到apache-ant-1.6.2\lib下,

  5.设置ant的环境变量:有ANT_HOME,PATH两项

  6.编写bulid.xml

  7.打包后在bulid.xml的同一目录下有一个MANIFEST.MF这个文件,可以把这个放到

  jar里面替换掉原来的,可以减小一点size.

  8.MicroEdition-Profile: MIDP-1.0

  MicroEdition-Configration: CLDC-1.0

  Media-Price: 5元每次

  这些只要手工加在jad里面就行,build.xml里面好像没有选项加这个。

  下面给出一个例子:bulid.xml

<?xml version="1.0"?> <project name="LoveNote_S40" default="build" basedir="."> <property name="build.compiler" value="classic"/> <!-- Define the Siemens Mobility Toolkit home directory. Needed by the tasks. --> <property name="wtk.home" value="C:\WTK104"/> <!-- Define some additional properties for this project. Not required. --> <property name="midlet.name" value="LoveNote_S40"/> <property name="midlet.home" value="."/> <!-- Define the tasks. --> <taskdef resource="antenna.properties"/> <target name="clean"> <delete failonerror="false" dir="classes"/> <delete failonerror="false"> <fileset dir="."> <exclude name="build.xml"/> </fileset> </delete> </target> <target name="build"> <!-- Create a JAD file. --> <wtkjad jadfile="LoveNote_S40.jad" jarfile="LoveNote_S40.jar" name="LoveNote" vendor="websurf tech co., inc." manifest="MANIFEST.MF" version="1.0"> <midlet name="LoveNote" icon="/icons/icon.png" class="GameMidlet"/> </wtkjad> <!-- Make sure we have a fresh classes directory. --> <delete dir="classes"/> <mkdir dir="classes"/> <!-- Compile everything, but don't preverify (yet). --> <wtkbuild srcdir="${midlet.home}" destdir="classes" preverify="false" encoding="utf-8"/> <!-- Package everything. --> <wtkpackage jarfile="${midlet.name}.jar" jadfile="${midlet.name}.jad" manifest="MANIFEST.MF" obfuscate="true"> <fileset dir="classes"/> <fileset dir="res"/> </wtkpackage> <!-- Preverify --> <wtkpreverify jarfile="${midlet.name}.jar" jadfile="${midlet.name}.jad" bootclasspath="${wtk.home}\lib\midpapi.zip" classpath="${wtk.home}\lib\ext\nokiaui.jar"/> <!-- Start the MIDlet suite <wtkrun jadfile="${midlet.name}.jad" wait="false" device="DefaultColorPhone"/> --> </target> </project>
0
相关文章