Post date: Sep 13, 2016 3:31:32 AM
pack200 utility in Java can reduce jar file size to ~67%. For example, 29KB size jar file is repacked and gziped with pack200 utility results 19KB gziped file which can used for applet loading. Here is the following process:
Compress Jar using pack200 utility
Create jar
Create jar using "jar" utility
Repack jar with pack200
Repack created jar with pack200 utility with the following options
Ex: pack200 -r --segment-limit=-1 --deflate-hint="keep" --unknown-attribute="pass" trinitiapplet.jar
Sign repacked jar
Sign the jar created from #2 step using jarsigner utility
Gzip-jar with pack200
Ex: pack200 trinitiapplet.jar.pack.gz trinitiapplet.jar
Include / Update html and jsp pages to load packed jars
Include Accept-Encoding in html and jsp pages, update html and jsp pages with the following line in <head> section
<meta HTTP-EQUIV="accept-encoding" CONTENT="pack200-gzip,gzip,deflate">
Include the following line in <applet> tag
<param name="java_arguments" value="-Djnlp.packEnabled=true" />
With the above approach html and jsp pages can load <jarname>.jar.pack.gz file from webserver if available, otherwise <jarname>.jar will be loaded automatically.
In one of the scenarios, 29KB of trinitiapplet.jar is reduced to 19KB of trinitiapplet.jar.pack.gz and 1938KB of etkclient.jar is reduced to 500KB of etkclient.jar.pack.gz.