EAR , JAR , WAR Archives in Java

J2EE defines three types of archives:

1. Java Archives (JAR) A JAR file encapsulates one or more Java classes, a manifest, and a descriptor. JAR files are the lowest level of archive. JAR files are used in J2EE for packaging EJBs and client-side Java Applications.

  • This archive file format is platform-independent format which has been fully written in Java.
  • The popular usage is to bundle all the .class files, and other required component files of a typical subsystem into a JAR file and include that JAR file into the CLASSPATH of another Java application which requires the services of that subsystem.
  • The maintenance and deployment becomes very easier in this case.
  • A JAR file has an optional manifest file located in the path META-INF/MANIFEST.MF. The entries in the manifest file determine how one can use the JAR file


2. Web Archives (WAR) WAR files are similar to JAR files, except that they are specifically for web applications made from Servlets, JSPs, and supporting classes.

  • It is used to package all the components of a Web Application.
  • It may contain JARs, JSPs, Servlets, HTMLs, GIFs, etc.
  • The purpose of this archive format is same as that of the JAR – to make the deployment, shipping, and in turn the maintenance process easier.
  • This will have an XML file fileName.xml as the Deployment Descriptor. This Deployment Descriptor is used by the Web Container to deploy the web application correctly.

3. Enterprise Archives (EAR) An EAR file contains all of the components that make up a particular J2EE application.

  • It is composed of several Web Applications and other independent JARs
  • The purpose is same – making deployment, shipping, and hence the maintenance easier.
  • Since Enterprise Application may have several web applications as its components, Hence EAR may contain WARs and JARs.
  • An EAR also contains an XML-based Deployement Descriptor, which is used by the Application Server to deploy the enterprise application correctly.

Tagged: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: