How do I update one file in a jar without repackaging the whole jar?

The simplest way to do is using 7-zip software. For

  1. Editing a file:

    • Open the jar file 7-zip | open archive
    • goto the file e.g. /Meta-Inf/xyz.conf
    • right mouse click and select 'open inside' option
    • edit the file and save the file
    • close the 7-zip console and it's done.
  2. For adding/replacing/removing a file.

    • Follow the first two steps till you reach the desired folder.
    • Removing: delete the file
    • Adding: Drag and drop the file to the 7-zip console.
    • close the console and it's done.

-C is changing the local directory, and is looking for hi.png there. It's not controlling where you're trying to inject it into the JAR file.

I would try making a new directory called images, moving your local hi.png into that, making images a child directory of your current working directory, then just run this:

jar uf myfile.jar images\hi.png

Tags:

Java

Jar