I have a batch file which does the following:
run the class through Proguard
and then through Jarg (Jogl actually breaks my class so i cannot use it )
This resultant class is then ‘packed’ and then ‘unpacked’ creating a class file which is even more compressable.
I then zip the final class file through different programs and settings (7zip, kzip and bwflate) and choose the best. (usually the bwflate zipped one is best)
Currently this brings the jar file down from 8,707 bytes when jar-ed using normal zip compression to 4,266 bytes (still need to optimize the code some more.)
my script (not easily transferable to other people’s computers but you get the gist of it:
del D:\eclipse\workspace\rally4k\basic.jar
mkdir D:\eclipse\workspace\rally4k\compressed
cd D:\eclipse\workspace\rally4k\compressed
d:
del *.* /Q
"D:\Program Files\7-Zip\7z.exe" a -tzip D:\eclipse\workspace\rally4k\basic.jar D:\eclipse\workspace\rally4k\Rally4k.class
java -jar D:\downloads\proguard3.5\proguard3.5\lib\proguard.jar @D:\eclipse\workspace\rally4k\settings.pro
java -jar D:\downloads\jarg-0.9.14\jarg.jar -main Rally4k D:\eclipse\workspace\rally4k\compressed\Rally4k_PG.jar
"D:\Program Files\7-Zip\7z.exe" x D:\eclipse\workspace\rally4k\compressed\Rally4k_PG_s.jar -oD:\eclipse\workspace\rally4k\compressed\
ren D:\eclipse\workspace\rally4k\compressed\Rally4k.class Rally4K.class.pre-pack&unpack
"C:\Program Files\Java\jdk1.5.0_04\bin\pack200.exe" --no-gzip D:\eclipse\workspace\rally4k\compressed\Rally4k.jar.pack D:\eclipse\workspace\rally4k\compressed\Rally4k_PG_s.jar
"C:\Program Files\Java\jdk1.5.0_04\bin\unpack200.exe" D:\eclipse\workspace\rally4k\compressed\Rally4k.jar.pack D:\eclipse\workspace\rally4k\compressed\Rally4k.jar.pack.unpacked.jar
"D:\Program Files\7-Zip\7z.exe" x D:\eclipse\workspace\rally4k\compressed\Rally4k.jar.pack.unpacked.jar -oD:\eclipse\workspace\rally4k\compressed\
"D:\Program Files\7-Zip\7z.exe" a -tzip D:\eclipse\workspace\rally4k\compressed\Rally4k_7z.jar D:\eclipse\workspace\rally4k\compressed\Rally4k.class -mx9 -mfb=255 -mpass=4
D:\downloads\kzip.exe /v /b64 D:\eclipse\workspace\rally4k\compressed\Rally4k.class(64).jar D:\eclipse\workspace\rally4k\compressed\Rally4k.class
D:\downloads\kzip.exe /v /b128 D:\eclipse\workspace\rally4k\compressed\Rally4k.class(128).jar D:\eclipse\workspace\rally4k\compressed\Rally4k.class
D:\downloads\kzip.exe /v /b256 D:\eclipse\workspace\rally4k\compressed\Rally4k.class(256).jar D:\eclipse\workspace\rally4k\compressed\Rally4k.class
D:\downloads\kzip.exe /v /b512 D:\eclipse\workspace\rally4k\compressed\Rally4k.class(512).jar D:\eclipse\workspace\rally4k\compressed\Rally4k.class
D:\downloads\kzip.exe /v /b1024 D:\eclipse\workspace\rally4k\compressed\Rally4k.class(1024).jar D:\eclipse\workspace\rally4k\compressed\Rally4k.class
D:\downloads\BJWFlate154\BJWFlate.exe -a -n D:\eclipse\workspace\rally4k\compressed\Rally4k.class.BWflate(120).jar D:\eclipse\workspace\rally4k\compressed\Rally4k.class
D:\downloads\BJWFlate154\BJWFlate.exe -a -n -s4096 D:\eclipse\workspace\rally4k\compressed\Rally4k.class.BWflate(4096).jar D:\eclipse\workspace\rally4k\compressed\Rally4k.class
D:\downloads\BJWFlate154\BJWFlate.exe -a -n -s8192 D:\eclipse\workspace\rally4k\compressed\Rally4k.class.BWflate(8192).jar D:\eclipse\workspace\rally4k\compressed\Rally4k.class