15

I have a jar, and I need to replace a class in it, at this moment, I can only open it with "archive manager" and then drag and drop the new compiled class into the jar, but I think this is really boring, if I can do with with just a command ?

Thanks ~

1
  • +1 for gui being boring :), but you should correct "archive manager"...
    – Johan
    Oct 18, 2010 at 5:45

2 Answers 2

18
zip -u stuff.jar file.txt

will update file.txt in stuff.zip . Note that for -u file.txt must already exist in the zip file, and will only be overwritten if it's newer than the one in the jar.

2
  • great tip. you could probably do it with 7-zip also.
    – djangofan
    Oct 18, 2010 at 5:03
  • Is there a solution if zip and jar are not available? I have only tar and gzip available
    – wutzebaer
    Jan 2, 2018 at 22:33
20

what about this one

jar -uf YOURJAR.jar FILE

if the jar have a folder structure, you can keep that too

jar -uf YOURJAR.jar DIR/DIR/FILE

Look this one for more information http://docs.oracle.com/javase/tutorial/deployment/jar/update.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .