Sep 19, 2018

How to update/modify a file inside a jar

The Jar tool provides a u option which you can use to update the contents of an existing JAR file by modifying its manifest or by adding files.
The basic command for adding files has this format:
jar uf jar-file input-file(s)
In this command:
  • The u option indicates that you want to update an existing JAR file.
  • The f option indicates that the JAR file to update is specified on the command line.
  • jar-file is the existing JAR file that is to be updated.
  • input-file(s) is a space-delimited list of one or more files that you want to add to the JAR file.
Any files already in the archive having the same pathname as a file being added will be overwritten.