Where's the compile n' shrink?

Where’s that delightful little web page?

It was crashy: some of the external processes like gasp javac, would hang and cause 100% CPU usage indefinitely. Last year I took the same source code, and used windows ports of kzip and others. The results were so bad (as in: not even close ) that I didn’t bother to continue the effort.

It’s really not rocket science… it’s just that you rely on external processes which either do a good or bad job.

For people who want a build environment on their home computer, there’s quite a bit of stuff in http://www.java-gaming.org/topics/indiespot-compression-not-working/25147/view.html

I can post my bash files if anyone wants them, but I think I really need to borrow some stuff from that thread instead.

Currently what I’m doing for speed/efficiency:

  1. Compile (my Eclipse compiles on save)
  2. JShrink GUI -> reopen “class” file, then save it as a JAR.
  3. Pack200 the resulting JAR:
pack200 -G -E9 -r G.pack200.jar G.jar
  1. Compare.

Sometimes I throw Proguard into the mix, but it tends to be pretty slow and annoying to use during development.

Proguard settings (Mac):

-libraryjars "/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar"
-injars "G.jar"
-outjars "G.proguard.jar"
-allowaccessmodification
-overloadaggressively
-defaultpackage ''
-keep public class G extends java.applet.Applet

Once I start getting closer to my byte budget, I’ll probably have to experiment with some other compression techniques…

Last year I worked on creating a bundle that can be used for an automated build. I’ve put that into a new Mercurial package out at my bucket site:

hg clone http://groboutils.hg.sourceforge.net:8000/hgroot/groboutils/java4k

It doesn’t bundle JShrink or yGuard due to licensing issues, nor does it include any of the compression programs.

Note that full builds with this can end up running for an hour, as it exhaustively checks different kzip settings to cut the size down by a few bytes.

Maybe an applet that uses the client’s processing power to generate the jar, instead of the server?

It would be an applet that has one text area for the java code, maybe the target jre, and one button to generate a jar that the user can somehow download from the applet. Possible?

That way that app can be hosted on java4k.com for posterity.

See my reply. :point: (Results were poor.)

When I used JShrink on one of my files, I nearly fell out of my seat. It reduced my Jar file by 1 KB!! It was enough to put it on J4k, but it was an application.

Needs a good Java zip library. kzip is only distributed as binary, and while 7zip is open source it would still need porting.

Hasn’t java got a built-in zipping library?

there should be a Java port on the offical site, there is also a lzma package on maven with normal io streams

lzma is not supported by the java plugin.

Yes, but it’s a bog standard one, and probably uses a simple greedy parser. A good zip library will squeeze a few more bytes out. As a quick test I’ve just compressed a group of already fairly well compressed programs I had sitting in my temp directory with both jar and kzip. jar got them down to 90.6% of the original size, and kzip to 88.6% of the original size.

Last year I used the script from Erik Byström:

Didn’t test it for Java 7.

I just happened to visit Charles Bloom’s web-site and ran across this (in case the are any folks with compression experience that are bored): http://cbloomrants.blogspot.fr/2012/01/01-09-12-lz-optimal-parse-with-star.html