Java-based packaging of jar, war, ear package and the difference between the detailed
From an end-customer perspective, a jar file is an encapsulation, and they don't need to know how many. class files are in the jar file, and the function and function of each file also gives them the desired result. In addition to the jar, there are war and ear ears for the Java EE.
Comparison Table
|
Jar |
War |
Ear |
English name |
java Archive file |
web Archive file |
enterprise Archive File |
Include content |
Class, properties file, is the smallest unit of file encapsulation, including Java Class Common library, resources, auxiliary files (auxiliary files), etc. |
Servlets, JSP pages, JSP tag libraries, jar library files, html/xml documents, and other common resource files, slices, audio files, etc. |
In addition to including jars and wars, EJB components are included |
Deployment files |
Application-client.xml |
Xml |
Application.xml |
Container |
Application Server (application servers) |
Small Service Program container (servlet containers) |
EJB container (EJB containers) |
Level |
Small |
In |
Big |
The role and difference of the 1.jar.war.ear package
I. Jar: Usually the development time to refer to the generic (JAVA) class, into a package for easy storage management;
II. War: is to do a (web) application, usually a Web site, into a package deployed into the container;
III. Ear: Enterprise applications, in fact, the ear package contains a war package and several enterprise-level project configuration files, the general server select WebSphere, etc., will use the ear package. Typically, an EJB is called into an ear packet.
2. When to use a war or jar file
I when your project is not fully completed, not suitable for the use of the war file, because your class will often change because of debugging, such as to delete, create a war file is very uncomfortable, preferably your project has been completed, do not change, then hit a war bag it, At this point a war file is equivalent to a Web application, and a jar file encapsulates a class and some related resources into a package for easy reference in the program.
Both the Ps:war package and the jar package are packaged using the jar command.
Java-based packaging of jar, war, ear package and the difference between the detailed