Ant problem with unjar

  • Thread starter Sebastian Berger
  • Start date

Sebastian Berger


I wrote the following ant build-file to create an obfusticated (with
proguard) jar-file:

<project name="test_biginteger" default="compile" basedir="..">
<property name="project" value="test_biginteger" />
<property name="WTK.dir" value="C:\Programme\WTK21"/>
<property name="MIDP.lib" value="${WTK.dir}\lib\midpapi20.jar" />
<property name="CLDC.lib" value="${WTK.dir}\lib\cldcapi11.jar" />

<!-- The following property is needed only for obufscate_proguard. -->
<property name="proguard" value="c:\Programme\proguard\lib\proguard.jar"/>

<path id="bootclasspath">
<pathelement path="${MIDP.lib}"/>
<pathelement path="${CLDC.lib}"/>

<path id="classpath">

<!-- INIT - execute any tasks required for the build -->
<target name="init">

<!-- Runs the application in the emulator. -->
<target name="run">
<exec executable="${midp}/bin/emulator">
<arg line="-classpath build/bin/${project}.jar"/>
<arg line="-Xdescriptor build/bin/${project}.jad"/>

<!-- Obufscates using ProGuard. -->
<target name="obfuscate_proguard" depends="compile, copylib">
<mkdir dir="build/proguard" />
<jar basedir="build/classes" jarfile="build/proguard/${project}-input.jar"
<java fork="yes" classname="proguard.ProGuard" classpath="${proguard}">
<arg line="-libraryjars ${MIDP.lib}" />
<arg line="-injars build/proguard/${project}-input.jar" />
<arg line="-outjar build/proguard/${project}-output.jar" />
<arg line="-keep 'public class * extends javax.microedition.midlet.MIDlet'"
<arg line="-defaultpackage" />
<arg line="-dontusemixedcaseclassnames" />
<mkdir dir="build/obfuscated" />
<unjar src="build/proguard/${project}-output.jar" dest="build/obfuscated" />

<!-- COMPILE - convert the source into class files -->
<target name="compile" depends="init">
<mkdir dir="build/classes" />
<javac destdir="build/classes" srcdir="src" target="1.1">
<bootclasspath refid="bootclasspath"/>

<!-- Unjars the library APIs in preparation for obfuscation. -->
<target name="copylib" depends="init">
<!-- <unjar src="libs/" dest="build/classes" /> -->
<unjar src="${MIDP.lib}" dest="build/classes" />
<unjar src="${CLDC.lib}" dest="build/classes" />


There is a problem in the unjar process. When ant wants to unjar the file
"midpapi20.jar" then I get the following exception:
java.lang.RuntimeException: data starting at 112 is in unknown format"

Do you have any idea for that error?

Thanks a lot in advance,

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

AspectJ and obfuscator 0
ant script, problem with classpath 4
ant taskdef problem 0
problem creating WAR file with ant 4
ant keeps compiling 3
Ant question 1
Problem with Ant 1
compile with ant 1

Members online

Forum statistics

Latest member

Latest Threads