This post is older than a year. Consider some information might not be accurate anymore.
The jar command allows you to manipulate Java Archives (JAR, EAR, WAR). This post demonstrates some examples.
The latest reference. Remember setting the correct path of your JDK in JAVA_HOME
environment variable.
List contents
List content template
jar tvf <java-archive>
Example: List contents of an (Enterprise Archive) ear file
C:\dev\src\appl\src\main\target> jar tvf appl.ear
0 Wed Jul 29 12:54:18 CEST 2015 META-INF/
153 Wed Jul 29 12:54:16 CEST 2015 META-INF/MANIFEST.MF
543 Wed Jul 29 09:31:22 CEST 2015 META-INF/application.xml
23593 Wed Jul 29 10:24:00 CEST 2015 ejb.jar
3754 Wed Jul 29 10:24:00 CEST 2015 helloworld.war
0 Wed Jul 29 12:54:18 CEST 2015 lib/
1599570 Wed Jul 29 10:02:30 CEST 2015 lib/axis.jar
79796 Wed Jul 29 10:02:30 CEST 2015 lib/commons-discovery.jar
61829 Wed Jul 29 10:02:30 CEST 2015 lib/commons-logging.jar
Extract files
Extract content/file template
jar xvf <java-archive> [<file>]
Example: Extract MANIFEST.MF
C:\dev\src\appl\src\main\target>jar xvf appl.ear META-INF/MANIFEST.MF
inflated: META-INF/MANIFEST.MF
Create archive
Example Create java archive with option M
= Does not create a manifest file entry.
C:\dev\src\appl\src\main\target> jar -cvfM appl.ear *
Update archive
The use case, patch the MANIFEST.MF and update it in the java archive. Example: Patch MANIFEST.MF file
C:\dev\src\appl\src\main\target> jar ufvm appl.ear META-INF/MANIFEST.MF