Antenna Package J2ME Program

Source: Internet
Author: User
Tags define command line join
Program | Package Antenna Package J2ME Program

Author: Jeru

Many people like to use ant to compile packaged Java applications, and it's easy to generate war packages running in the Java EE container, and I also saw an article on Sun's website
tutorial on using ant to package J2ME programs: http://wireless.java.sun.com/midp/articles/ant/

Test a bit, but also good, but the drawback is that the need to write their own MANIFEST.MF and jad documents, so the heart is unwilling to continue to search on Google,
Finally found a very powerful ant expansion pack, specialized packaging J2ME program, very practical: http://antenna.sourceforge.net/
You can automatically compile, precompile, generate JAR,JAD,PRC (Palm's running program), and even include scrambled code. All you have to do is change the parameters in Build.xml less.

Below take Uidemo For example, give everybody share the process of packing. (This article applies to users who have experience with Ant)

First of all, assume that you have used the ANT,ANT_HOME environment variable has been set up, the above Web site to download the Antenna-bin.jar to join Classpath
I set up a uidemo directory under D:\My folder\projects\j2me\, and took the RES,SRC two directories under J2mewtk\apps\uidemo to come here,
A build.xml file is created under the same level directory, and the Build.xml content is as follows, and only a few areas of the Chinese annotation need to be modified:

<?xml version= "1.0"?>

<project name= "Uidemo" default= "Build" basedir= "." >

<!--Define the Wireless Toolkit home directory. Needed by the tasks. -->
<!--set the J2MEWTK path. -->
<property name= "Wtk.home" value= "C:\J2MEWTK"/>

<!--Define Some additional properties for this project. Not required. -->

<!--set MIDlet name and root path. -->
<property name= "Midlet.name" value= "Uidemo"/>
<property name= "Midlet.home" value= "." />

<!--Define the tasks. -->

<taskdef name= "Wtkjad" classname= "De.pleumann.antenna.WtkJad"/>
<taskdef name= "Wtkbuild" classname= "De.pleumann.antenna.WtkBuild"/>
<taskdef name= "Wtkpackage" classname= "De.pleumann.antenna.WtkPackage"/>
<taskdef name= "WTKMAKEPRC" classname= "DE.PLEUMANN.ANTENNA.WTKMAKEPRC"/>
<taskdef name= "Wtkrun" classname= "De.pleumann.antenna.WtkRun"/>
<taskdef name= "wtkpreverify" classname= "De.pleumann.antenna.WtkPreverify"/>
<taskdef name= "Wtkobfuscate" classname= "De.pleumann.antenna.WtkObfuscate"/>

<target name= "clean" >
<delete failonerror= "false" dir= "classes"/>
<delete failonerror= "false" >
<fileset dir= "." >
<exclude name= "Build.xml"/>
</fileset>
</delete>
</target>

<target name= "Build" >


<!--creat a new jad-->
<!--specify MIDlet classes and icons. -->
<wtkjad jadfile= "${midlet.name}.jad"
Name= "Sun Samples-demos"
Vendor= "Sun Microsystems"
version= "1.0.3" >
<midlet name= "Uidemo"
icon= "/res/midp/uidemo/icon.png"
class= "Midp.uidemo.UIDemo"/>

</wtkjad>
<mkdir dir= "Classes"/>

<!--Compile everything, but don ' t preverify (yet). -->

<wtkbuild srcdir= "${midlet.home}/src"
Destdir= "Classes"
Preverify= "false"/>


<!--Package everything. Most of the necessary information is
Contained in the JAD file. Also preverify The result this
Time. To obfuscate everything, set the corresponding
parameter to "true" (requires Retroguard or Proguard). The
Version parameter increments the midlet-version by one. -->

<!--settings need to be scrambled, whether to precompile, and whether version--> is automatically recognized
<wtkpackage jarfile= "${midlet.name}.jar"
Jadfile= "${midlet.name}.jad"
Obfuscate= "false"
Preverify= "true"
Autoversion= "true" >

<!--Package Our newly compiled classes and the
Resources from the WTK ' s demo application. -->

<fileset dir= "Classes"/>
<fileset dir= "${midlet.home}/res"/>


</wtkpackage>

<!--Convert the JAR file into a MIDP for PalmOS PRC file. -->

&LT;WTKMAKEPRC jadfile= "${midlet.name}.jad"
prcfile= "${MIDLET.NAME}.PRC"/>

<!--Start the MIDlet suite-->

<wtkrun jadfile= "${midlet.name}.jad" device= "Defaultcolorphone"/>

</target>

</project>

Finally run ant at the command line, it's all that simple.

Finally, incidentally, the installation of ANT, but also very simple, download back to set the environment variable ant_home to the installation directory, will%ant_home%\bin join the path to the




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.