Difference between jar and war in Java
Solution 1
From Java Tips: Difference between ear jar and war files:
These files are simply zipped files using the java jar tool. These files are created for different purposes. Here is the description of these files:
.jar files: The .jar files contain libraries, resources and accessories files like property files.
.war files: The war file contains the web application that can be deployed on any servlet/jsp container. The .war file contains jsp, html, javascript and other files necessary for the development of web applications.
Official Sun/Oracle descriptions:
Wikipedia articles:
Solution 2
WAR stands for Web application ARchive
JAR stands for Java ARchive
Solution 3
A .war
file has a specific structure in terms of where certain files will be. Other than that, yes, it's just a .jar
.
Solution 4
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.
(source)
So a .war is a .jar, but it contains web application components and is laid out according to a specific structure. A .war is designed to be deployed to a web application server such as Tomcat or Jetty or a Java EE server such as JBoss or Glassfish.
Solution 5
A .war
file is a Web Application Archive which runs inside an application server while a .jar
is Java Application Archive that runs a desktop application on a user's machine.
helpermethod
Updated on July 08, 2022Comments
-
helpermethod almost 2 years
What is the difference between a
.jar
and a.war
file?
Is it only the file extension or is there something more?