Search code examples
javadeploymentjarjarsigner

How to reduce size of Jar files for update OR what is the best method to update Jar file


We have an application consisting of two three files of size 130 MB 40 MB and 70 MB, initially while installing we send the whole Jar files together with other files such as jre, database setup files which makes the total zip of 700 MB. Now for updating the application, we again have the send the whole Jar files which makes the combined size of 240 MB, which is too much for updating an application. What is the best way of updating a JAR file without sending the whole jar.


Solution

  • Are you 'striping' your jars? 130MB for a bunch of class files is a humongous size, which makes me think that you've either striped (unpacked a whole bunch of deps and then repacked them into a single giant jar, or in this case, evidently, 3 of them), or you've included large resources such as a big background image for your app in these jars.

    Undo that - don't stripe, and have your app deployment be a sizable amount of jar files. If you have a bunch of resources (such as said large background image), make sure these end up building into different jars; your build tool should have support for this.

    At that point, you have lots of smaller jars and 'an update' most likely means only a few of the jars have changed at all. Thus, it now is a matter of sending the hashes of those jars to a central server, with that server reporting back: Okay, you only need updates for this, that, and the other jar, but not the rest.

    jars are already compressed, so at that point, just send those jars.