"jar -uvf" to Update a JAR with New Files

Q

What is the "jar" command to update an existing JAR file with new or additional files?

✍: FYIcenter.com

A

To update an existing JAR file with new or additional files, you can use the "jar -uvf jarname files" command.

For example, the following session updates an existing JAR file with some additional classes:

\fyicenter>"%java_home%\bin\jar" -xvf jms.jar

\fyicenter>"%java_home%\bin\jar" -cvf myNew.jar .\javax

\fyicenter>"%java_home%\bin\javac" Hello.java

\fyicenter>"%java_home%\bin\jar" -uvf myNew.jar Hello.class
adding: Hello.class(in = 416) (out= 286)(deflated 31%)

\fyicenter>"%java_home%\bin\jar" -tf myNew.jar
META-INF/
META-INF/MANIFEST.MF
javax/
javax/jms/
javax/jms/BytesMessage.class
javax/jms/Connection.class
javax/jms/ConnectionConsumer.class
...
javax/jms/XATopicConnectionFactory.class
javax/jms/XATopicSession.class
Hello.class

Back to FAQ for JDK JAR (Java ARchive) Tool.

2016-09-25, 3799🔥, 1💬