Is there are way to patch jar files?

落花浮王杯 提交于 2019-12-01 02:29:48

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

You can copy the modified .class file this way.

jar uf test.jar com\test\Test.class

If there is a logical way for you to separate out your components in individual jar files then I would create a jar file per component type. That way you will not have re-distribute everything back to the client. For example - take a look at how Spring 3 has the components separated out.

There is JARDiff, designed for updating Java WebStart applications.

You will need to rebuild the entire jar file unless you want them to unjar, overwrite a file and rejar.

Take a look at the usage of jar command. The option u lets you update an existing archive.

Just open up your jar file with 7zip and overwrite the classes you have edited. Make sure to make a backup first though.

If you have your old and new jar file, you can create an xdelta of both and send only the delta file to your client, which should be much smaller than the whole jar file, if you changed only one class of many. This should work for signed jars, too, but requires that both sender and receiver have the xdelta program (or be able to install it).

And of course, you have to create the new jar first (but this can be done by the methods already mentioned by the other answers).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!