Skip to content
  • Facebook
GeekCer Logo

GeekCer

The geek's Coding education and Review centre

  • Home
  • Tutorials
    • Java
    • Servlet
    • JSP
    • Python
    • C Tutorial
    • Spring
    • Spring Boot
    • MongoDB
    • Hibernate
    • Data Structure
  • General Knowledge
  • Biography
  • Grammar
  • Festival (त्योहार)
  • Interview
  • Differences
  • Important
  • Toggle search form

Home » Servlet » What is WAR file in Java?

  • जन्माष्टमी व्रत पूजा विस्तार से | दही हांडी | Krishna Janmashtami Puja
    जन्माष्टमी व्रत पूजा विस्तार से, दही हांडी: Krishna Janmashtami Puja Festival
  • Chemical Properties of Matter (Element, Compound and Mixture)
    Chemical Properties of Matter examples (Element, Compound and Mixture) Science
  • Farmers Day
    National Farmers Day in Hindi | राष्ट्रीय किसान दिवस पर निबंध | चौधरी चरण सिंह जयंती General Knowledge
  • Thomas Edison Biography in Hindi - थॉमस एडिसन जीवनी
    Thomas Edison Biography in Hindi – थॉमस एडिसन जीवनी Biography
  • Sawan ka Mahina : सावन का महीना का महत्व, भगवान शिव की पूजा
    Sawan ka Mahina : सावन का महीना का महत्व, भगवान शिव की पूजा Festival
  • Fundamental Rights of Indian Citizens
    Fundamental Rights of Indian Citizens | मौलिक अधिकार क्या हैं? General Knowledge
  • Lata Mangeshkar Biography In Hindi | लता मंगेशकर संपूर्ण जीवन परिचय
    Lata Mangeshkar Biography In Hindi | लता मंगेशकर संपूर्ण जीवन परिचय Biography
  • States of Matter : Physical Properties of Matter (Solid, Liquid, Gas)
    States of Matter | Physical Properties of Matter (Solid, Liquid, Gas) Science

What is WAR file in Java?

Posted on August 31, 2021May 17, 2022 By GeekCer Education No Comments on What is WAR file in Java?
What is WAR file in Java

We use the WAR file in Java to package the web application which may contains servlet, xml, jsp, image, html, css, js etc. It has .war extension. A WAR file can be digitally signed just like a JAR file to allow others to determine where the source code came from.

Table of Contents

  • What resources are usually involved in WAR file?
  • What is the directory structure of a web application in Java?
    • The structure of the web application deployment descriptor file looks like this:
  • What are the advantages of WAR file?
  • How to create a .war file?
  • Difference between WAR and JAR file in Java

What resources are usually involved in WAR file?

A WAR usually contains following resources:

  • Servlets, JavaServer Pages (JSP), Custom Tag Libraries.
  • Server-side utility classes (database beans, shopping carts, and so on).
  • Static web resources (HTML, image, and sound files, and so on).
  • Client-side classes (applets and utility classes).

What is the directory structure of a web application in Java?

The directory structure of a web application consists of two parts. The first part is the public directory structure consisting of HTML/XML documents, JSP pages, images, applets, etc. The second part is a special WEB-INF directory.

The WEB-INF directory that contains the following files and directories:

  • web.xml (The web application deployment descriptor.)
  • Tag Library Descriptor files.
  • classes/ (A directory that contains server-side classes: servlet, utility classes, and JavaBeans components.)
  • lib/ (A directory that contains JAR archives of libraries.)
  • tags/ (A directory that contains Tag files)

The structure of the web application deployment descriptor file looks like this:

                  WEB-INF/
WEB-INF/web.xml
WEB-INF/classes/
WEB-INF/lib/
WEB-INF/tags/

What are the advantages of WAR file?

There are following advantages of WAR files:

  • Web applications become easier to test and deploy.
  • Identifying the version of the deployed application becomes easy.
  • Makes smooth deployment.
  • WAR files are supported by all Java EE containers.
  • MVC structure supports WAR files.

How to create a .war file?

                  jar cvf java_webapp.war *

Here, java_webapp is the web application name. -c creates file, -v to generate the verbose output and -f to specify the archive file name.

Difference between WAR and JAR file in Java

  • You will need a web server or web container such as Tomcat or WebLogic or WebSphere to execute WAR file. A simple JDK is sufficient to execute a JAR file.
  • WAR has a predefined structure with WEB-INF and META-INF directories, whereas you can create JAR with any structure.
  • You can use WAR files only for web application where you can use JAR files to package library, plugin, or any types of application.

Also Read:

What are the APIs in Servlet?
Create servlet in Java (Steps)

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • More
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Also Read

Servlet Tags:How to create war file in java using command prompt?

Post navigation

Previous Post: Servlet API | Packages and Examples of the Servlet API
Next Post: HTTP status codes List | Response Status Code Glossary

More Related Articles

Steps to Create a Servlet Steps to Create a Servlet Servlet
HTTP status codes List | Response Status Code Glossary HTTP status codes List | Response Status Code Glossary Important
Servlet API Servlet API | Packages and Examples of the Servlet API Servlet
Servlet Tutorial Servlet Tutorial Servlet

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Servlet Home
  • Steps to Create a Servlet
  • Servlet API
  • What is WAR File?
  • National Farmers Day in Hindi | राष्ट्रीय किसान दिवस पर निबंध | चौधरी चरण सिंह जयंती
  • Human rights day in Hindi: 10 दिसंबर ह्यूमन राइट्स डे
  • Unicef day is celebrated on December 11 | Speech on unicef day
  • Indian Navy Day: जल सेना दिवस कब और क्यों मनाया जाता है?
  • P V Sindhu Biography in Hindi, Badminton, State, Caste पी. वी. सिंधु जीवन परिचय, कहानी, राज्य, जाति
  • Draupadi Murmu Biography In Hindi | द्रौपदी मुर्मू की जीवनी
  • Similarities and difference between OSI and TCP/IP model
    OSI vs TCP/IP Model, Similarities and difference between OSI and TCP/IP model Networking
  • Difference between TCP and UDP
    Difference between TCP and UDP | TCP vs UDP examples Differences
  • IPv4 Vs IPv6 | Difference between IPv4 and IPv6
    IPv4 Vs IPv6 | Difference between IPv4 and IPv6 Differences
  • Difference between Internet and Intranet
    Difference between Internet and Intranet Differences
  • TCP/IP Model, Full Form, Layers and their Functions
    TCP/IP Model, Full Form, Layers and their Functions Networking
  • OSI Model | 7 Layers of OSI Model in Computer network
    OSI Model | 7 Layers of OSI Model in Computer network, Functions Networking
  • Network kya hai (नेटवर्क क्या है)
    Network kya hai (नेटवर्क क्या है) Networking
  • Java Tutorial
  • Servlet Tutorial
  • JSP Tutorial
  • Maven Tutorial
  • HTML Tutorial
  • Programs
  • Hindi/English Grammar
  • Difference Between ... and ...
  • HR Interview
  • Important Articles

Write to Us:
geekcer.code@gmail.com

  • About Us
  • Privacy and Policy
  • Disclaimer
  • Contact Us
  • Sitemap

Copyright © GeekCer 2022 All Rights reserved