Tuesday, December 4, 2012

Differences between ear, jar and war files

Lets see the similarities and differences between ear, jar and war files.
All these files are simply zipped files using java jar tool, but they are created for different purposes.

JAR files
The .jar files contain the libraries, resources and accessories files like property files. JAR file could have an optional Manifest file, which contains package and extension related data.

The Manifest file will have the name MANIFEST.MF. This manifest file belongs to the optional directory named META-INF. This directory is used to store package and extension configuration data, security related data, versioning related data, services related data, etc.

WAR files
A WAR file (or Web application ARchive) is a JAR file used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static Web pages (HTML and related files) and other resources that together construct a Web application.
The WEB-INF directory in the WAR file contains a file named web.xml which defines the structure of the web application. web.xml file is known as the Deployment Descriptor. This Deployment Descriptor is used by the Web Container to deploy the web application correctly.

EAR files
An EAR file has JAR file structure. As an addition it has:
  • one or more entries representing the modules of the application
  • metadata directory META-INF which contains one or more deployment descriptors.
The .ear files make deployment, shipping, and the maintenance easier.
An enterprise application may be composed of several Web Applications and other independent JARs. This archive file format is used in those cases to bundle all the components of an enterprise application into a single file.

The META-INF directory contains at least the application.xml, known as the Java EE Deployment Descriptor. It is used by the Application Server to deploy the enterprise application correctly.


No comments:

Post a Comment