What is the difference between Ear, Jar, War files in Java?

** Reprinted from  http://apps.hi.baidu.com/share/detail/30355098

 

What's the difference between Ear, Jar, War files? In which environment are they used?

  In terms of file structure, the three are not different, they all use the zip or jar archive file compression format. But they are used for different purposes:

  Jar files (extension .jar) contain common libraries, resources, auxiliary files, etc. of Java classes

  A War file (with the extension .War) contains the entire web application. In this case, a Web application is defined as a single set of files, classes, and resources, and the user can encapsulate the jar file and access it as a small service program (servlet).

  Ear files (with the extension .Ear) contain all enterprise applications. In this case, an enterprise application is defined as a collection of jar files, resources, classes, and web applications.

  Each type of file (.jar, .war, .ear) can only be processed by application servers, servlet containers, EJB containers, etc. ]

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

From the end customer's point of view, a .jar file is a kind of encapsulation, they don't need to know how many .class files are in the .jar file, and the functions and functions in each file can also get the results they want. In addition to jar, there are war and ear for J2EE. The difference is shown in the table below:

 

 

JAR

WAR

EAR

English Java Archive file   Web Archive file Enterprise Archive file
Included class and properties files are the smallest unit of file encapsulation; Servlet, JSP page, JSP tag library, JAR library file, HTML/XML document and other public resource files, such as pictures, audio files, etc.; In addition to containing JAR, WAR, also includes EJB components
deployment file application-client.xml web.xml    application.xml
level little middle

 

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

These three files can be regarded as java compression formats, and their essence is to achieve different encapsulation:

jar -- package class
war--package web site
ear--encapsulate ejb.
Their relationship is specifically:
jar: is java Achieve--class package compressed in java format, including content class, properties files, is the minimum unit level of file encapsulation: small
war: is a file web Achieve--including Servlet, JSP page, JSP tag library, JAR library file HTML/XML document and other common resource files, such as pictures, audio files, etc. Level: Medium
ear: is the file Enterprise Achieve--in addition to including JAR, WAR, but also EJB components Deployment file application-client.xml web.xml application.xml level: large
A web component developer performs the following tasks to deliver a WAR file containing the web component:
| Write and compile servlet source code
| Write jsp, html files
| Specify the development descriptor of the web
| Bind .class, .jsp, .html and deployment descriptors to a WAR file.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324510965&siteId=291194637