File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java Micro Edition and the fly likes Problem packing with ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Problem packing with ant" Watch "Problem packing with ant" New topic

Problem packing with ant

Mercor Fitzpatrick

Joined: Aug 21, 2006
Posts: 2

I'm having a hard time packing a J2ME application w/ ant.
The scenario is this: my ant does all the job right (compile, preverify, and package w/o warnings or errors). Though, when I deploy and run it on my Nokia 6230 (or emulator) I get the following error message:

java/lang/VerifyError: net/benhui/btgallery/spp_gui/SPP_MIDlet

The funny thing is that when I create a package w/ the EclipseME plug-in, the application runs smoothly.

I would really appreciate if anyone could take a look on the following ant script, and point out what I might be getting wrong.


<path id="project.classpath">
<pathelement location="lib/jsr082.jar"/> <!-- [jsr082] -->
<pathelement location="lib/cldcapi11.jar"/> <!-- [cldcapi11] -->
<pathelement location="lib/midpapi20.jar"/> <!-- [midpapi20] -->
<property name="project.classpath" refid="project.classpath"/>

<target name="init" >
<mkdir dir="${TARGET_DIR}"/>

<target name="compile" depends="init" >
<mkdir dir="${TARGET_DIR}/classes"/>
<javac srcdir="${SRC_DIR}" destdir="${TARGET_DIR}/classes" source="1.3" target="1.1">
<bootclasspath refid="project.classpath"/>

<target name="preverify" depends="compile">
<mkdir dir="${TARGET_DIR}/preverified"/>
<exec executable="${J2ME_HOME}/bin/preverify">
<arg line="-classpath ${project.classpath}"/>
<arg line="-d ${TARGET_DIR}/preverified"/>
<arg line="${TARGET_DIR}/classes"/>
<arg line="-target CLDC1.1"/>

<target name="jar" depends="preverify">
<mkdir dir="${TARGET_DIR}/dist"/>
<jar basedir="${TARGET_DIR}/classes" jarfile="${TARGET_DIR}/dist/BenhuiMIDlet.jar" >
<attribute name="MIDlet-Version" value="1.0.0"/>
<attribute name="MIDlet-Vendor" value="Midlet Suite Vendor"/>
<attribute name="MIDlet-Jar-URL" value="BenhuiMIDlet.jar"/>
<attribute name="MicroEdition-Configuration" value="CLDC-1.1"/>
<attribute name="MicroEdition-Profile" value="MIDP-2.0"/>
<attribute name="MIDlet-1" value="SPP_MIDlet,,net.benhui.btgallery.spp_gui.SPP_MIDlet"/>
<attribute name="MIDlet-Name" value="Midlet Suite"/>
<copy file="util/BenhuiMIDlet.jad" tofile="${TARGET_DIR}/dist/BenhuiMIDlet.jad"/>
Rashid Mayes
Ranch Hand

Joined: Jan 11, 2006
Posts: 160
From a quick glance, it may be that the jar is built from the ${TARGET_DIR}/classes and not from ${TARGET_DIR}/preverified.

I also use ant to package my midlets. Here is the preverify step from one of the build scripts:

In the example above, the jar is created first and the preverify step processes the jar file.

Rashid Mayes -
Mercor Fitzpatrick

Joined: Aug 21, 2006
Posts: 2
Thanks Rashid!

I really appreciate the time you took taking a glance at my script... it helped MUCH more than the many hours I had spent in vain searching the web.

I agree. Here's the link:
subject: Problem packing with ant
It's not a secret anymore!