Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Automate Your J2ME Application Porting with Preprocessing : Page 5

Got porting nightmares? If you're considering automating the porting your J2ME applications, you may want to think about using a preprocessor. Find out why it's the only technique open-ended enough to handle porting to multiple device models.


advertisement
Building the Preprocessed Source Code
Next, build the preprocessed source code, which means compiling the two files you've created.

The name of the .jad file and its content are specified in the tag:

<wtkjad jadfile="output\bin\${midlet.name}.jad" jarfile="output\bin\${midlet.name}.jar" name="${midlet.name}" vendor="You" version="1.0" target=""> <midlet name="${midlet.name}" icon="/icon.png" class="game.${midlet.name}"/> <attribute name="MIDlet-Icon" value="/icon.png"/> </wtkjad≫

It's advisable to always use the same name for the icon (for instance, icon.png).



To package the midlet, create the .jar file. Select the resources to be integrated in your .jad file. Here are some simple guidelines for this process:

  • Separate graphics for different types of screens (big screens, medium screens, small screens, etc.).
  • Separate the icons of each size in a sub-directory (res_icon32x32, res_icon16x16, etc.).
  • Separate the resources for sounds (res_midifiles, res_ottfiles, etc.).
In Table 3, the left column describes the code in the right column.

 

<?xml version="1.0"?>

Name the project.

<project name="MyMidletProject" default="build" basedir=".">

Specify where to find WTK.

  <property name="wtk.home" value="c:\WTK23\"/>

Specify the midlet name.

  <property name="midlet.name" value="MyFirstMidlet"/>

 

  <property name="midlet.home" value="${wtk.home}/apps/${midlet.name}"/>

Specify the standards APIs you use (WMA, MMAPI, PDAP, 3D, Bluetooth, Web services).

  <property name="wtk.wma.enabled" value="false"/>

  <property name="wtk.mmapi.enabled" value="true"/>

  <property name="wtk.optionalpda.enabled" value="false"/>

  <property name="wtk.java3d.enabled" value="false"/>

  <property name="wtk.bluetooth.enabled" value="false"/>

  <property name="wtk.j2mews.enabled" value="false"/>

Specify the CLDC version.

  <property name="wtk.cldc.version" value="1.0"/>

Specify the MIDP version (MIDP 1 or MIDP 2) :

-         <property name="wtk.midp.version" value="1.0"/>

-         <property name="wtk.midp.version" value="2.0"/>

  <property name="wtk.midp.version" value="2.0"/>

Specify the proprietary APIs (Nokia Serie40, Nokia Serie60, …).

-         <property name="wtk.midpapi" value="c:\libs\nokia_s40\classes.zip"/>

-         <property name="wtk.midpapi" value="c:\libs\nokia_s60v2\j2me-debug.zip"/>

 

 

  <taskdef resource="antenna.properties"/>

Clean the classes directory.

  <target name="clean">

    <delete failonerror="false" dir="classes"/>

    <delete failonerror="false">

      <fileset dir=".">

        <exclude name="build.xml"/>

      </fileset>

    </delete>

  </target>

 

  <target name="build">

Clean the output directories: output\bin, output\classes, output\src

    <delete dir="output\bin" verbose="false"/>

    <delete dir="output\classes" verbose="false"/>

    <delete dir="output\src" verbose="false"/>

    <mkdir dir="output\bin"/>

    <mkdir dir="output\classes"/>

    <mkdir dir="output\src"/>

Launch the pre-processor process

    <wtkpreprocess srcdir="src" destdir="output\src" symbols="MIDP2" verbose="false"/>

Launch the compilation process

    <wtkbuild srcdir="output\src" destdir="output\classes"/>

Launch the packaging process

    <wtkjad jadfile="output\bin\${midlet.name}.jad"

      jarfile="output\bin\${midlet.name}.jar"

      name="${midlet.name}"

      vendor="You"

      version="1.0"

      target="">

      <midlet name="${midlet.name}" icon="/icon.png" class="game.${midlet.name}"/>

      <attribute name="MIDlet-Icon" value="/icon.png"/>

    </wtkjad>

 

   <wtkpackage jarfile="output\bin\${midlet.name}.jar" jadfile="output\bin\${midlet.name}.jad" obfuscate="false" preverify="false">

      <fileset dir="output\classes"/>

Include the resources (for the big screens or for the small screens).

-         <fileset dir="res_bigscreen"/>

-         <fileset dir="res_smallscreen"/>

      <fileset dir="res_bigscreen"/>

Include the icon (format 32x32 or 16x16) :

-         <fileset dir="res_icon_32x32"/>

-         <fileset dir="res_icon_16x16"/>

      <fileset dir="res_icon_16x16"/>

Include the sounds files (midi files or ott files) :

-         <fileset dir="res_midifiles"/>

-         <fileset dir="res_ottfiles"/>

      <fileset dir="res_midifiles"/>

 

      <preserve class="game.${midlet.name}"/>

    </wtkpackage>

 

  </target>

</project>


Table 3. Building the Preprocessed Code.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap