Linux command for extracting war file?

JavaLinuxWar

Java Problem Overview


How can I extract a .war file with Linux command prompt?

Java Solutions


Solution 1 - Java

Using unzip

unzip -c whatever.war META-INF/MANIFEST.MF  

It will print the output in terminal.

And for extracting all the files,

 unzip whatever.war

Using jar

jar xvf test.war

Note! The jar command will extract war contents to current directory. Not to a subdirectory (like Tomcat does).

Solution 2 - Java

Or

> jar xvf myproject.war

Solution 3 - Java

A war file is just a zip file with a specific directory structure. So you can use unzip or the jar tool for unzipping.

But you probably don't want to do that. If you add the war file into the webapps directory of Tomcat the Tomcat will take care of extracting/installing the war file.

Solution 4 - Java

You can use the unzip command.

Solution 5 - Java

Extracting a specific folder (directory) within war file:

# unzip <war file> '<folder to extract/*>' -d <destination path> 
unzip app##123.war 'some-dir/*' -d extracted/

You get ./extracted/some-dir/ as a result.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionammarView Question on Stackoverflow
Solution 1 - JavajmjView Answer on Stackoverflow
Solution 2 - JavaRaghuramView Answer on Stackoverflow
Solution 3 - JavaKdeveloperView Answer on Stackoverflow
Solution 4 - JavatangensView Answer on Stackoverflow
Solution 5 - JavaNuxView Answer on Stackoverflow