Is there are way to patch jar files?

GC_ picture GC_ · Feb 21, 2011 · Viewed 21.2k times · Source

Suppose I sent a large jar or war file to someone. Could I later just change one small section and send that to him? Suppose I just changed one class file. I recompiled the java for into a class file. Other then exchanging the new class file for the old class file it there anything else I would have to do?

In java do you have to rebuild the entire jar/war file? Also, is there some open source package available for doing updates?

Answer

Jeremy picture Jeremy · Feb 21, 2011

The person receiving the class file could simply add that file to the jar as long as they know which directory to put it in. Be weary of signed jars, as noted in the comments.

jar uf foo.jar foo.class

http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/jar.html