Current location - Quotes Website - Personality signature - What's the difference between jar package and war package?
What's the difference between jar package and war package?
The difference between jar package and war package:

1, war is a web module, which needs to contain WEB-INF, so just run it directly. Jar generally only contains some class files, which can be run with java commands after declaring Main_class.

2. The 2.war package is a web application, usually a website, packaged and deployed in a container; Jar package is usually a general class to be referenced during development, and it is easy to store and manage after packaging.

3.war is a Web application format proposed by Sun, and it is also a compressed package of many files. The files in this package are organized according to a certain directory structure; Classes directory contains compiled Servlet classes and other classes that Jsp or Servlet depends on (such as JavaBean), which can be packaged into jars and placed in the lib directory under WEB-INF.

JAR file format is based on the popular ZIP file format. Different from ZIP files, JAR files are not only used for compression and publishing, but also for deploying and encapsulating libraries, components and plug-ins, which can be directly used by compilers, JVMs and other tools.

Format characteristics:

Security can digitally sign the contents of JAR files. In this way, the tool that can recognize the signature can selectively grant you software security rights, which other files can't do, and it can also detect whether the code has been tampered with.

Reduce download time if an applet is bundled into a JAR file, then the browser can download it through HTTP? Instead of opening a new connection for each file, download the applet's class files and related resources in a transaction.

Compression: JAR format allows you to compress files to improve storage efficiency.

Transmission platform extension: The Java extension framework provides a way to add functions to the Java core platform. Are these extensions implemented in JAR? File packaging (Java 3D and JavaMail are extended examples developed by Sun).

WAR file: It is a Web application. Creating a WAR file is to compress the entire Web application (excluding the root directory of the Web application hierarchy) and specify a war extension.

Conditions for establishment:

It is necessary to establish a correct hierarchy of Web application directories.

Create a WEB-INF subdirectory, and create two subdirectories under this directory, classes and lib.

Put Servlet class files in the WEB-INF\classes directory, and put Java class library files (JAR files) used by WEB applications in the WEB-INF\lib directory.

Put JSP pages or static HTML pages under the context root path or its subdirectories.

Establish a META-INF directory, and create a context.xml file under this directory.