How to Extract War File
A WAR file in Java is a JAR file containing web-based components like servlets, HTML property files, resources, etc. WAR is short for Web Application Archive
, a file that archives all the necessary components to efficiently transfer a file from a server to a client. In this tutorial, we will see how we can extract a generated WAR file.
Steps to Extract a WAR File Using Command Line/Terminal
-
Open the folder where the WAR file is located. It is usually in the project folder, like shown below.
-
Open the command line/terminal and type the command
jar
-xvf
nameOfTheWarFile.war
.Here in the command, the first main command item,
jar
, creates an archive or restores them from an archive. To extract the archived WAR file, we use the command optionx
that extracts the contents of the file, then to print the logs of the process on the command line/terminal, we use thev
command option. The optionf
specifies the name of the WAR file and we write the file’s path in the last.Following is an example of a command prompt screen after the WAR file has been extracted. We can see that the logs specify the creation and inflation of a few files.
-
Now, we check the folder where we extracted the file. There will be a few files like as shown below. The WAR has been successfully extracted.
Extract a WAR File by Renaming It
Another quick way to extract the WAR file is to rename it and change its file extension. To do this, we first locate the file, then we change its name from theWarFile.war
to theWarFile.zip
. Notice that war
and zip
are file extensions. Now, we use a tool or functionality to extract any normal zip
file.
Rupam Saini is an android developer, who also works sometimes as a web developer., He likes to read books and write about various things.
LinkedIn