Robot Butler
  Making those complicated tasks nice and easy.
  A hub for guides, walkthroughs and general information.
Follow us on Twitter RSS Feed
Article Image JAR files are basically an archive of other files needed to run Java applications. This normally consists of classes, support files and general content needed for the program to work properly. JAR files are normally already compressed but not as well as they could be. Sometimes this is good enough, but if you're streaming the application over the internet often or need to store them on space restricted devices then more compression is ideal.

To do this we will be using the Pack200 application that comes with Java's JRE. If you don't have Java's JRE for whatever reason, then you can find it here.

On Windows you will find the Pack200 application in a path similar to Program Files / Java / bin and on Linux you can just run the application directly as it will already be in your path.

To repack your JAR file to use the best compression possible, use the following command, replacing the example filename at the end with the location of your own JAR file:

pack200 --repack --effort=9 --segment-limit=-1 --modification-time=latest --strip-debug myfile.jar

You can now check the size of the file and depending on the previous compression you should find it's at least a little smaller than it was before. Over time that can add up, alternatively it may now fit on a mobile device that it previously wouldn't.


No comments yet.

Post a Comment

    Email (not displayed)

The name of this website is Robot...      


  • 14 categories
  • 50 articles

Site, design and code by Benjamin Hodgetts.