EARs, WARs, JARs, and Java EE

A Java EE application may contain one or more Java EE components such as EJBs, Web modules, resource adapters, or J2EE application client modules. Each Java EE component can have an associated deployment descriptor — an XML file that describes the component. Java enterprise components are deployed using the Java Archive (JAR) file format, which branches into additional formats to handle various component types.
The Java Archive (JAR) file format is based on the ZIP file format and enables you to bundle multiple Java EE components into a single file. A JAR file can contain Java class files, XML descriptor files, auxiliary resources, static HTML files, and other files associated with each Java EE component. A standard Java Web application is deployed in a Web Application Archive (WAR) file, which is a JAR file with the extension of .war. A standard Java EE application is deployed in an Enterprise Application Archive (EAR) file, which is a JAR file with an extension of .ear.
A WAR file is a specialized JAR file containing Web application components such as servlets, JSP files, HTML files, deployment descriptors, utility JAR files, etc. A WAR file can be deployed to a Web server such as Tomcat.
An EAR file is a specialized JAR file containing Java EE application components such as Web applications (WAR files), EJBs, resource adapters, etc. An EAR file can be deployed to a Java EE application server such as JBoss, WebLogic, or WebSphere. Java EE application servers load EAR files at runtime and deploy the components found within each file as Web applications, resource adapters, EJBs, and so on, based on the instructions found in each component’s deployment descriptor.
An EAR file can contain multiple Web applications along with other resources and auxiliary components. Deploying an application as an EAR file within the structure of a Java EE application server environment enables the app server to isolate each Web application within a separate class-loading and resource-loading context. Web applications in the Java EE app server environment can share resources in common, such as utility class files.
In a Java EE environment, specialized containers are designated to handle component isolation and resource sharing. These containers are, in turn, managed by the application server. Containers provide an isolated context wherein Java EE components are deployed and execute. Containers provide an abstraction layer between the components, ensuring that they seldom interact directly. Instead, components can use the protocols and APIs of the container to interface with each other and with other application services. This layer of abstraction enables containers to provide ancillary services required by the component, such as pooling, transaction management, and state management.