Basic popularization-jar, War, Ear

Source: Internet
Author: User
noun explanation jar file (with the extension. Jar)

A War file, such as a generic library, resource (resources), secondary file (auxiliary files), that contains Java classes (with a. war extension)

Contains all 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). 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. The ear file includes the entire project, containing multiple EJB module (jar files) and Web module (war file)

function War Package:

encapsulates the class. is to do a Web application, usually a Web site, into a package deployed into the container. jar Package:

Encapsulates a Web site. Typically, it is development time to refer to a generic class, which is packed to facilitate storage management. Ear Package:

Encapsulates an EJB. Enterprise-class applications, usually EJB-like ear packs.

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

The war package can be placed in either the WebApps or the work directory, and as Tomcat starts, it can be uncompressed automatically. Then the IE can be accessed via Http://localhost:8080/XXXX. Or you can publish the war package through the Tomcat Admin page, which is actually copying the war package into the WebApps directory.

contrast

Jar

WAR

EAR

English

Java Archive File

Web Archive File

Enterprise Archive File

Include content

Java class, properties file, etc., 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

Big

Jar/war/ear three kinds of files, 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:

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. Packing Method packaging with Java commands

The prerequisite is that you have the JDK installed in your machine, and you add the JDK's Bin directory in the environment variable path.

You can package the war and jar packages with JAR commands, and then play jar packs

Here's how to use the example


This example is the COM directory in the package class directory, and if you want to package all the contents of the class directory, you can use

Java code

1. JAR-CVF Test.jar * Play War package

The war package is the same usage just the directory you are packing should be the root of the Web application.


War package winrar Open directory that's it.

You can configure the parameters for using the jar command according to your own needs. using tools Eclipse Export War Package


Click the right mouse button on the item

The following figure


Select War Click Next

Select the path of the project and the war you want to export and click Finish.
Export Jar file method similar, please study it yourself. It's me who's lazy.

Generate Ear

1. Create a new project Select Enterprise Application project in Java EE

2. New Dynamic Web Engineering Web-> Dynamics Web project

Note: ADD Project to the ear option to tick the new project name in the first step of the ear project name selection on the next line

3. Right-click Web project name Select Export-> java ee-> ear File in Ear project, select the first step of the project name, destiantion add the package path and name. And the ditch. Overwrite existing File

using MAVEN to generate an ear package

1. First, you have to install Maven

2. One of the business particles that will be packaged from SVN (developed on a single line in the cloud platform)

3. Right-click the Project→configure→convertto Maven Project you want to package, waiting to be packaged.


The knowledge we use every day is really not necessarily understood, this time should be as far as possible to avoid the situation, the most basic things we should be clear, and then it is possible to upgrade their own instances on the higher level. Otherwise, the faster you run, the higher you jump, the more ruthless you fall.

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.