I thought it might be helpful to people who have never used Ant before to show a build script that can make shrinking your jar much easier. With the click of a button, you can compile, obfuscate, unzip and rezip from an Ant build file. This will also make it easier to experiment better with each option.
<project name="Asteroids4k" default="compile" basedir=".">
<taskdef resource="proguard/ant/task.properties" classpath="C:/Apps/Programming/Java/proguard3.4/lib/proguard.jar" />
<taskdef name="jarg" classname="jarg.JargTask" classpath="C:/Apps/Programming/Java/jarg/jarg.jar" />
<description>
Ant build script for Asteroids, Java 4K entry
</description>
<!-- Global properties for this script -->
<property environment="env" />
<property name="j4k.root" location="${basedir}" />
<property name="j4k.src" location="${j4k.root}/src" />
<property name="j4k.bin" location="${j4k.root}/bin" />
<property name="j4k.dist" location="${j4k.root}/dist" />
<target name="init">
<echo>${ant.version}</echo>
<!-- Creates a time stamp -->
<tstamp>
<format property="timestamp" pattern="yyyyMMddHHmmss" />
</tstamp>
<!-- Create the classes directory structure -->
<mkdir dir="${j4k.bin}" />
<mkdir dir="${j4k.dist}" />
</target>
<target name="compile" depends="init" description="compiles all source files">
<!-- Compile the java code from ${j4k.src} into ${bin} -->
<javac destdir="${j4k.bin}" debug="off" deprecation="off">
<src path="${j4k.src}" />
<include name="**/*.java" />
</javac>
</target>
<target name="recompile" depends="clean, compile" description="rebuilds the project" />
<target name="clean" description="deletes classes and archive directories">
<!-- Delete the output directory trees -->
<delete dir="${j4k.bin}" />
<delete dir="${j4k.dist}" />
</target>
<target name="build" depends="_rezip" description="deletes classes and archive directories">
</target>
<target name="build_2" depends="_obfuscate" description="deletes classes and archive directories">
</target>
<target name="rebuild" depends="clean, build" description="rebuilds the project" />
<target name="_package_jar" depends="compile" description="generate the jar file">
<zip destfile="${j4k.dist}/Asteroids4Kpre.jar" compress="yes">
<fileset dir="${j4k.bin}">
<include name="*.*" />
<include name="*" />
</fileset>
</zip>
</target>
<target name="_re_package_jar" depends="clean, _package_jar" description="generate the jar file">
<zip destfile="${j4k.dist}/Asteroids4Kpre.jar">
<fileset dir="${j4k.bin}">
<include name="*.*" />
<include name="*" />
</fileset>
</zip>
</target>
<target name="_obfuscate" depends="_rezip" description="obfuscate/compress classes">
<proguard verbose="true">
-keep public class A {
public static void main(java.lang.String[]);
}
<injar path="${j4k.dist}/Asteroids4Kpre.jar" />
<outjar path="${j4k.dist}/Asteroids4K.jar" />
<libraryjar path="C:/Apps/Programming/Java/j2sdk1.4.2_10/jre/lib/rt.jar" />
</proguard>
</target>
<target name="_obfuscate_2" depends="_package_jar" description="obfuscate/compress classes">
<jarg jarfile="${j4k.dist}/Asteroids4Kpre.jar" verbose="true" rnlog="rnlog.txt" />
</target>
<target name="_unzip" depends="_obfuscate_2" description="obfuscate/compress classes">
<unzip src="${j4k.dist}/Asteroids4Kpre_s.jar" dest="${j4k.dist}" />
</target>
<target name="_rezip" depends="_unzip" description="obfuscate/compress classes" >
<exec executable="7z" output="error.log" dir="${j4k.dist}">
<arg value="a" />
<arg value="Asteroids.jar" />
<arg value="A.class" />
</exec>
</target>
</project>