0

I am following question to update a file content inside the jar And run following command

jar tvf <jarfileName>

and then

jar xvf <FullFilePath>

and at last

jar vuf <FolderName>/

So what exactly happening here , in jar i have structure like this

Foo.jar (root directory)
/
|->/folder1
|
|->/folder2
|
|->/foo
    |
    |-->/bar
         |
         |---->/baz
               |
               |------>file1
               |------>file2
               |------>file3
               |------>file..N

After running above commands ,jar folder Structure change like this

Foo.jar (root directory)
/
|
|->/foo
    |
    |-->/bar
         |
         |---->/baz
               |
               |------>file1
               

It is deleting everything and update with only file and folder structure which was extracted.

Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202

1 Answers1

0

In case you are not limited to using jar command only, I would offer as one of the solutions to use any zip utils because jar file is a plain old zip archive.

You can unpack it to the folder, replace all required files and pack it back again.

You can do it with internal java zip support or use other tools to work with zip files from java like zip4jvm.

P.S. zip4jvm is written by me

Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202
Oleg Cherednik
  • 17,377
  • 4
  • 21
  • 35