I am making a game that needs to be updated.
I have two JAR files: Update.Jar and Game.Jar
Basically, I want to be able to modify Game.Jar without completely overwriting it.
I want to:
- Open the Jar file as a Zip file from within code
- Replace/add some resources
- Repackage the Jar file.
Is there an easy way or classes that can do this? If not, what would be the cleanest approach to doing this?
A Java JAR file is a normal ZIP file. You can therefore open and modify it with code dealing with ZIPs.
Here’s a snippet which works (courtesy of David):