I prepared Ant script that can be used for the most of Java ME projects. It encapsulates all low-level detail dealing with tools/callses from Java ME platform.
1. Specify project name and default target:
<project name="MyFirstMidlet" default="compile" basedir=".">
2. Define useful properties that will be used throughout the project:
<property name="java.mobile.home" value="c:/Java/j2me-2.3"/>
<property name="midlet.class.name" value="${ant.project.name}"/>
<property name="src.dir" value="src"/>
<property name="target.dir" value="target"/>
<property name="midlet.command.line" value=""/>
3. Specify the classpath that includes core mobile API and required extension APIs, e.g.:
<path id="mobile.classpath">
<pathelement location="${java.mobile.home}/lib/cldcapi11.jar"/>
<pathelement location="${java.mobile.home}/lib/midpapi20.jar"/>
<pathelement location="${java.mobile.home}/lib/wma20.jar"/>
<pathelement location="${java.mobile.home}/lib/mmapi.jar"/>
<pathelement location="${java.mobile.home}/lib/j2me-ws.jar"/>
<pathelement location="${java.mobile.home}/lib/jsr75.jar"/>
<pathelement location="${java.mobile.home}/lib/jsr082.jar"/>
<pathelement location="${java.mobile.home}/lib/jsr184.jar"/>
<pathelement location="${java.mobile.home}/lib/jsr179.jar"/>
<pathelement location="${java.mobile.home}/lib/jsr177.jar"/>
<pathelement location="${java.mobile.home}/lib/jsr211.jar"/>
</path>
4. We need to create string version of our classpath. It will be used for executables, like "preverified.exe" and "emulator.exe":
<property name="mobile.classpath" refid="mobile.classpath"/>
5. Prepare "compile" target. Keep in mind that target attribute should be on "1.1" level:
<target name="compile">
<mkdir dir="${target.dir}/classes"/>
<javac srcdir="${src.dir}" destdir="${target.dir}/classes"
bootclasspathref="mobile.classpath"
source="1.1" target="1.1"/>
</target>
6. Compiled classes should be "preverified". It means that each class file in "classes" directory will have corresponding "preverified" class file in "preverified" directory.
<target name="preverify" depends="compile">
<mkdir dir="${target.dir}/preverified"/>
<exec executable="${java.mobile.home}/bin/preverify">
<arg line="-classpath ${mobile.classpath}"/>
<arg line="-d ${target.dir}/preverified"/>
<arg line="${target.dir}/classes"/>
</exec>
</target>
7. Resulting jar file will contain "preverified" classes and resources from "res"
directory:
<target name="jar" depends="preverify">
<mkdir dir="${target.dir}/bin"/>
<jar basedir="${target.dir}/preverified"
jarfile="${target.dir}/bin/${ant.project.name}.jar"
manifest="bin/MANIFEST.MF">
<fileset dir="res"/>
</jar>
<copy file="bin/${ant.project.name}.jad"
tofile="${target.dir}/bin/${ant.project.name}.jad"/>
</target>
8. In order to run generated artifact you have to launch the emulator. You can run
emulator as executable file or as java class.
- as executable:
<target name="run2" depends="jar">
<exec executable="${java.mobile.home}/bin/emulator">
<!-- device: DefaultColorPhone, DefaultGrayPhone, MediaControlSkin, QwertyDevice -->
<arg line="-Xdevice:DefaultColorPhone"/>
<arg line="-Xdescriptor:${basedir}/${target.dir}/bin/${ant.project.name}.jad"/>
<arg line="-classpath ${mobile.classpath};${basedir}/${target.dir}/bin/${ant.project.name}.jar"/>
</exec>
</target>
- as java class:
<target name="run" depends="jar">
<java fork="yes" classname="com.sun.kvem.environment.EmulatorWrapper">
<sysproperty key="kvem.home" value="${java.mobile.home}"/>
<sysproperty key="java.library.path" value="${java.mobile.home}/bin"/>
<sysproperty key="sun.java2d.ddlock" value="true"/>
<sysproperty key="sun.java2d.gdiblit" value="false"/>
<arg line="-Xdevice:DefaultGrayPhone"/>
<arg line="-Xdescriptor:${basedir}/${target.dir}/bin/${ant.project.name}.jad"/>
<arg line="-classpath ${mobile.classpath};${target.dir}/bin/${ant.project.name}.jar"/>
<arg line="${midlet.class.name}"/>
<arg line="${midlet.command.line}"/>
<arg line="0"/>
</java>
</target>
-
5 comments:
Good dispatch and this fill someone in on helped me alot in my college assignement. Gratefulness you on your information.
Brim over I agree but I about the list inform should have more info then it has.
Genial fill someone in on and this mail helped me alot in my college assignement. Thanks you on your information.
Today I was specially registered at a forum to participate in discussion of this question.
ray ban 3186 are usually smooth. they're made having a streamlined look. one more pattern may be the wraparound Ray ban sunglasses.They are pretty well-liked amidst sports activities personalities generally because of its futuristic appeal. These wraparound ray ban 3212 typically have polycarbonate lens and sturdy grip to produce total vision security accompanied using the awesome and classy look. dfgkcxy0rtw The display is immensely common and has led towards the generation of the really personal manufacturer title ray ban 3269 , amongst other products and solutions which include a movie game.All Ray ban sunglasses lens are created of shatter evidence polycarbonate and offer 100% ultra violet protection. So, even as you have older,
ray ban 3322 you can even now ride the street with obvious and sharp vision.Every pair of genuine Orange County Ray ban sunglasses arrives with it's personal leather-based bound case. several huge and well-liked custom homes on a regular basis roll-out their ray ban 3359 ranges that are prepared with exceptional vision gear, ideal acuity, and assortment of features.
Post a Comment