What is the difference between an ear, Jar, and war file in Java? __java

Source: Internet
Author: User
Tags pack java format

What is the difference between an Ear, Jar, and war file? What kind of environment they are used separately.

In the file structure, the three are not different, they are in the zip or jar file compression format. But they are used for different purposes:

Jar file (with the extension. Jar) contains common libraries, resources, and auxiliary files (auxiliary files) for Java classes

The war file (. war extension) contains all the Web applications. In this case, a Web application is defined as a separate set of files, classes, and resources, and the user can encapsulate the jar file and access it as a small service program (servlet).

The ear file (. ear extension) contains all enterprise applications. In this case, an enterprise application is defined as a collection of multiple jar files, resources, classes, and Web applications.

Each file (. jar,. War,. Ear) can only be handled by the application server (application servers), the Small Service program container (servlet containers), the EJB container (EJB containers), and so on. ]

================================================================

From the perspective of the end customer, the. jar file is an encapsulation, and they don't need to know how many. class files in a jar file, the functions and roles in each file, can also get the results they want. Besides jars, there are war and ear for the Java EE. The difference is shown in the following table:

Jar

WAR

EAR

English Java Archive File Web Archive File Enterprise Archive File
Include content Class, properties file, is the smallest unit of file encapsulation; Servlet, JSP pages, JSP tag libraries, jar library files, html/xml documents, and other common resource files, such as pictures, audio files, and so on; In addition to containing jars, war, EJB components are included
Deployment files Application-client.xml Xml Application.xml
Level Small In

=================================================================

These three kinds of files can be considered as Java compression format, and its essence is to achieve a different encapsulation:

jar--Encapsulation Class

war--Encapsulation Web site

ear--encapsulates EJBs.

Their relationship is specific to:

Jar: Java achieve--is compressed in Java Format class package, contains content class, properties file, is the file encapsulation of the smallest unit level: small

War: is the file Web achieve--contains servlet, JSP page, JSP Tag library, jar library file Html/xml document and other common resource files, such as pictures, audio files, and other levels: medium

Ear: Is the file Enterprise achieve--includes the EJB component deployment file Application-client.xml Web.xml Application.xml level in addition to containing jars, war: Large

In the file structure, the three are not different, they are in the zip or jar file compression format. But they are used for different purposes:

Jar file (with the extension. Jar) contains common libraries, resources, and auxiliary files (auxiliary files) for Java classes

The war file (. war extension) contains all the Web applications. In this case, a Web application is defined as a separate set of files, classes, and resources, and the user can encapsulate the jar file and access it as a small service program (servlet).

The ear file (. ear extension) contains all enterprise applications. In this case, an enterprise application is defined as a collection of multiple jar files, resources, classes, and Web applications.

Each file (. jar,. War,. Ear) can only be handled by the application server (application servers), the Small Service program container (servlet containers), the EJB container (EJB containers), and so on. ]

All packages are made of jars, except that the target file has a different extension.

Ear Pack: Enterprise-class applications, usually EJB-typed as an ear package. The ear is the extension of the Java EE application file

It's enterprise Application achiever,

is a packaged enterprise application that can contain war (Web application Archiever), EJB, etc.

Ear Pack: Enterprise-class applications, usually EJB-typed as an ear package.

War Package: A Web application is a good one, usually a Web site, packed into a container.

Jar Packages: Usually the development time to refer to the common class, the package for easy storage management.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.