.jar文件和.war文件有什么区别? 仅仅是文件扩展名还是还有其他的东西?


当前回答

You add web components to a J2EE application in a package called a web application archive (WAR), which is a JAR similar to the package used for Java class libraries. A WAR usually contains other resources besides web components, including: Server-side utility classes (database beans, shopping carts, and so on). Static web resources (HTML, image, and sound files, and so on) Client-side classes (applets and utility classes) A WAR has a specific hierarchical directory structure. The top-level directory of a WAR is the document root of the application. The document root is where JSP pages, client-side classes and archives, and static web resources are stored.

(源)

所以。war是一个。jar,但它包含web应用程序组件,并根据特定的结构进行布局。.war被设计为部署到web应用服务器(如Tomcat或Jetty)或Java EE服务器(如JBoss或Glassfish)。

其他回答

.war文件是运行在应用服务器内部的Web应用程序存档文件,而.jar文件是在用户机器上运行桌面应用程序的Java应用程序存档文件。

基本上都是压缩档案。War用于具有特定目录结构的web应用程序。

.jar和.war都是压缩的归档文件。 两者都可以有可选的META-INF/MANIFEST。MF清单文件,其中包含信息信息,如版本控制,以及将执行它的JVM的类路径和主类等指导性属性。

.war文件- Web应用程序归档文件打算在“Servlet容器”中执行,可能包括其他jar文件(在Web - inf /lib目录)编译类(在Web - inf /classes (Servlet也在那里)).jsp文件图像,文件等。 所有的WAR内容,以便创建一个自包含的模块。

You add web components to a J2EE application in a package called a web application archive (WAR), which is a JAR similar to the package used for Java class libraries. A WAR usually contains other resources besides web components, including: Server-side utility classes (database beans, shopping carts, and so on). Static web resources (HTML, image, and sound files, and so on) Client-side classes (applets and utility classes) A WAR has a specific hierarchical directory structure. The top-level directory of a WAR is the document root of the application. The document root is where JSP pages, client-side classes and archives, and static web resources are stored.

(源)

所以。war是一个。jar,但它包含web应用程序组件,并根据特定的结构进行布局。.war被设计为部署到web应用服务器(如Tomcat或Jetty)或Java EE服务器(如JBoss或Glassfish)。

战争——

分发基于java的web应用程序。WAR具有相同的文件 结构作为JAR文件,这是一个单独的压缩文件 包含多个捆绑在其中的文件。

Jar——

jar文件包含库、资源和附件文件 比如属性文件。 WAR文件用于组合jsp、servlet、Java类文件和XML 文件,javascript库,JAR库,静态网页等等 运行应用程序所需的其他资源。