11

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 for gui being boring :), but you should correct "archive manager"... – Johan Oct 18 '10 at 5:45
11
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.

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.