Basic Universal-jar, War, Ear

Source: Internet
Author: User

The noun explains the jar file with the extension. Jar)

Generic libraries, resources, auxiliary files (auxiliary files), etc. that contain Java classes

War file (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 (with. 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, with multiple EJB module (jar files) and Web module (war file)

Action War Pack:

Encapsulates a class. is to do a Web application, usually a Web site, into a package deployed into a container.

Jar Package:

Encapsulates a Web site. It is usually a generic class to be referenced at development time, and a package facilitates storage management.

Ear Package:

Encapsulates an EJB. An enterprise-class application, typically an EJB into an ear package.

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

The war package can be placed in the WebApps or work directory, and it can be extracted automatically with the launch of Tomcat. Then the IE can be accessed via Http://localhost:8080/XXXX. Or you can publish the war package via the Tomcat admin page, which actually copies the war package to the WebApps directory.

Contrast

JAR

WAR

EAR

English

Java Archive File

Web Archive File

Enterprise Archive File

Include content

Java class , properties files, 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, slices, audio files, etc.;

in additionto including jars and wars, EJB components are included

Deployment files

Application-client.xml

Web. 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 the purpose of their use is different:

Each file (. jar,. War,. Ear) can only be processed by the application server (application servers), the Small service container (servlet containers), the EJB container (EJB containers), and so on, respectively.

Packaged by Java commands

The premise is that you have a JDK installed in your machine, and you add the bin directory of the JDK to the environment variable path.

The jar command can be used to package the war and jar packages,

Hit Jar bag

Here's how to use the example


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

Java code

1. JAR-CVF Test.jar *

Fight a war bag

It's the same with a war bag. Only the directory you pack should be the root of your web app.


War pack WinRAR Open Directory this is it.

You can configure parameters that use the jar command according to your needs.

Export a war package using tool eclipse


Right-click on the item

Such as


Select War Click Next

Select the project to export and the path to the war, click Finish.
Export Jar file method similar, please study it yourself. It's my own laziness!

Generate Ear

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

2. New Dynamic Web Engineering Web project

Note: The ADD project to an ear option is checked in the next line of the ear project name in the first step of the new project name

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

Using MAVEN to generate an ear package

1. First of all, MAVEN must be installed.

2. Download one of the business particles that will be packaged from SVN (the cloud platform is developed in one line)

3. Right-click the Project→configure→convertto Maven Project you want to package and wait for it to be packaged.


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

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Basic Universal-jar, War, Ear

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.