0

I developed a j2me application, it is working fine.

In my application I have build.xml, when I run this build.xml it is generated a jar and jad files.

But the here the build is failed but the jar and jad are created, when I run that jad the application is not running.

please help me how to write build.xml in j2me, the following is my build.xml

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

<!-- set global properties for this build -->

    <taskdef resource="antenna.properties" classpath="../antenna/antenna-bin-1.2.1-beta.jar" />

    <property name="lib" location="../lib" />

    <property name="program_name" value="DEMO" />
    <property name="package_name" value="DEMO" />

    <property name="midp_home" value="C:/WTK2.5.2_01" />
    <property name="wtk.home" value="C:/WTK2.5.2_01" />
    <property name="wtk.midp.version" value="2.0" />
    <property name="wtk.cldc.version" value="1.1" />

    <path id="lib.path">
            <fileset dir="${lib}">
                    <include name="LWUIT.jar"/>
            </fileset>
    </path>

    <property name="src" value="src" />
    <property name="res" value="res" />
    <property name="build" value="build" />
    <property name="dist" value="dist" />

    <!--Create the build directory structure used by compile and dist-->
    <target name="init">
        <delete dir="${build}" />
        <delete dir="${dist}" />

        <mkdir dir="${build}" />
        <mkdir dir="${dist}" />
        <mkdir dir="${build}/classes" />
    </target>

    <!-- Compile Source -->
    <target name="compile" depends="init">
        <wtkbuild srcdir="src" destdir="${build}/classes" preverify="false">
           <classpath refid="lib.path"/>
        </wtkbuild>

      <unjar src="../lib/LWUIT.jar" dest="${build}/classes" />

    </target> 

    <!-- Creat build and Preverify  -->
    <target name="package" depends="compile" >

    <wtkjad jadfile="${dist}\${program_name}.jad" manifest="${dist}/MANIFEST.MF"
            jarfile="${dist}\${program_name}.jar" name="DEMO"
            vendor="xyz" version="1.2">
            <midlet name="DEMO" icon="/i.png" class="MM" />
            <attribute name="endpoint"
                value="http://localhost/j2meservice" />
            <attribute name="MicroEdition-Configuration" value="CLDC-1.1"/> 
            <attribute name="MicroEdition-Profile" value=" MIDP-2.0"/>
            <attribute name="MIDlet-Description" value=" Smart Phones"/>
            <attribute name="devicetype" value="bb" />
        </wtkjad>


        <wtkpackage jarfile="${dist}/${program_name}.jar"
           jadfile="${dist}/${program_name}.jad" obfuscate="false"
            preverify="false">

            <fileset dir="${build}/classes" includes="**/*.class" />
            <fileset dir="${res}" includes="**" />
        </wtkpackage>
    </target>

    <target name="obfuscate" depends="package">
            <wtkobfuscate jarfile="${dist}/${program_name}.jar"
                    jadfile="${dist}/${program_name}.jad" obfuscator="proguard" >
                <argument value="-defaultpackage"/>
                <argument value="-repackageclasses"/>
                </wtkobfuscate>
            </target>

    <target name="preverify" depends="obfuscate">
       <wtkpreverify jarfile="${dist}/${program_name}.jar" jadfile="${dist}/${program_name}.jad" >
       </wtkpreverify>
   </target>

   <target name="build" depends="preverify">
   </target>

    <target name="run">
        <exec executable="${midp_home}/bin/emulator">
            <arg line="-Xdescriptor:${dist}/${program_name}.jad" />
        </exec>
    </target>

</project>

this the output of my build.xml

Buildfile: D:\eclipse-pulsar-copy-workspace\DEMO\build.xml
init:
   [delete] Deleting directory D:\eclipse-pulsar-copy-workspace\DEMO\build
   [delete] Deleting directory D:\eclipse-pulsar-copy-workspace\DEMO\dist
    [mkdir] Created dir: D:\eclipse-pulsar-copy-workspace\DEMO\build
    [mkdir] Created dir: D:\eclipse-pulsar-copy-workspace\DEMO\dist
    [mkdir] Created dir: D:\eclipse-pulsar-copy-workspace\DEMO\build\classes
compile:
 [wtkbuild] **************************************************************
 [wtkbuild] * Antenna 1.2.1 initialized for project "DEMO"          *
 [wtkbuild] * Using "Sun Wireless Toolkit 2.5" (CLDC-1.1; MIDP-2.0)      *
 [wtkbuild] **************************************************************
 [wtkbuild] Compiling 705 source files to D:\eclipse-pulsar-copy-workspace\DEMO\build\classes
 [wtkbuild] Note: Some input files use or override a deprecated API.
 [wtkbuild] Note: Recompile with -Xlint:deprecation for details.
    [unjar] Expanding: D:\eclipse-pulsar-copy-workspace\lib\LWUIT.jar into D:\eclipse-pulsar-copy-workspace\DEMO\build\classes
package:
   [wtkjad] Creating JAD file D:\eclipse-pulsar-copy-workspace\DEMO\dist\DEMO.jad
   [wtkjad] Creating MANIFEST file D:\eclipse-pulsar-copy-workspace\DEMO\dist\MANIFEST.MF
[wtkpackage] Building jar: D:\eclipse-pulsar-copy-workspace\DEMO\dist\DEMO.jar
[wtkpackage] Updating JAD file D:\eclipse-pulsar-copy-workspace\DEMO\dist\DEMO.jad
obfuscate:
[wtkobfuscate] Obfuscating D:\eclipse-pulsar-copy-workspace\DEMO\dist\DEMO.jar with ProGuard
[wtkobfuscate] ProGuard, version 4.8
[wtkobfuscate] Reading input...
[wtkobfuscate] Reading program jar [D:\eclipse-pulsar-copy-workspace\DEMO\dist\DEMO.jar]
[wtkobfuscate] Reading library jar [C:\WTK2.5.2_01\lib\cldcapi11.jar]
[wtkobfuscate] Reading library jar [C:\WTK2.5.2_01\lib\midpapi20.jar]
[wtkobfuscate] Initializing...
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Image2D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Image2D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Image2D
[wtkobfuscate] Warning: com.sun.lwuit.M3G$Callback: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileSystemRegistry
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileSystemRegistry
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Note: com.sun.lwuit.M3G: can't find dynamically referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class com.siemens.mp.game.Light
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class com.motorola.phonebook.PhoneBookRecord
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class com.nokia.mid.ui.FullCanvas
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class net.rim.device.api.system.Application
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class com.mot.iden.util.Base64
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class mmpp.media.MediaPlayer
[wtkobfuscate] Note: there were 7 unresolved dynamic references to classes or interfaces.
[wtkobfuscate] Warning: there were 31 unresolved references to classes or interfaces.
[wtkobfuscate]       You should check if you need to specify additional program jars.
[wtkobfuscate]          You may need to specify additional library jars (using '-libraryjars').
[wtkobfuscate] java.io.IOException: Please correct the above warnings first.
[wtkobfuscate]  at proguard.Initializer.execute(Initializer.java:321)
[wtkobfuscate]  at proguard.ProGuard.initialize(ProGuard.java:212)
[wtkobfuscate]  at proguard.ProGuard.execute(ProGuard.java:87)
[wtkobfuscate]  at proguard.ProGuard.main(ProGuard.java:493)

BUILD FAILED
D:\eclipse-pulsar-copy-workspace\DEMO\build.xml:75: Obfuscation failed (result=1)

Total time: 28 seconds

How build this successfully ?

thanks and regards

gnat
  • 6,213
  • 108
  • 53
  • 73
  • 1
    Build.xml file means that You use Apache Ant to build Your project. Please see this link (http://ant.apache.org/) and try to read something about Ant. – tostao Jan 08 '13 at 11:27

1 Answers1

2

This has nothing to do with the build.xml. You are linking against the LWUIT.jar which is the generic library instead of the MIDP version of LWUIT which is what you want.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65