Sitemap

JAR vs. WAR

3 min readDec 2, 2025

--

JAR

JAR (Java ARchive) is a compressed file format used to distribute Java applications or libraries.

Features

  • Bundles Java class files (.class), resources (images, property files, etc.), and metadata (MANIFEST.MF, etc.) into a single file, simplifying distribution and management.
  • JAR defines a MANIFEST file containing the Main-Class attribute to create an application that can be executed directly.
  • It can be executed via the command (java -jar) without a separate web server, requiring only the JVM and JRE.

WAR

WAR (Web Application Archive) is a file format used to package Java web applications for deployment to web servers or WAS.

Features

  • WAR files have a predefined directory structure (WEB-INF, META-INF, etc.).
  • Includes deployment descriptors like Servlets, JSPs, static resources, and web.xml
  • Cannot be executed directly; must be deployed and run within a web container like Tomcat, WebLogic, or WebSphere
  • Highly versatile for compatibility with diverse web server environments and integration into large-scale web systems

Comparison

Press enter or click to view image in full size

Conclusion

JAR files offer the advantages of standalone execution and rapid deployment,
while
WAR files provide compatibility with large-scale systems and a standard web application structure.
In practice, when using embedded application servers like
Spring Boot, deploying a single executable JAR file is straightforward.
For traditional web systems and integration with application servers,
WAR files are more suitable.

Appendix

JVM (Java Virtual Machine): Bytecode execution engine

  • A virtual machine that interprets and executes Java bytecode (.class files) to run on various operating systems
  • Enables Java application execution tailored to the operating system
    Handles memory management, garbage collection, thread management, security, etc.
  • Thanks to the JVM, Java achieves WORA (Write Once, Run Anywhere), meaning it operates platform-independently

Get leedohyung28’s stories in your inbox

Join Medium for free to get updates from this writer.

JRE (Java Runtime Environment): Runtime environment package

  • Provides the environment (runtime environment) to execute Java programs
  • A package containing the JVM, Java standard library, and other resource files
    Non-developer users only need to run programs, so installing the JRE alone suffices
  • The JRE is included in the JDK but does not contain development tools

MANIFEST file: Defines classpath and metadata

  • Located in the META-INF/ folder inside JAR or WAR files; a text file describing various metadata about the archive
  • Primary uses include setting the application entry point, defining the classpath, specifying version information, etc.\

Servlet

  • A server-side program written in Java
  • Receives and processes HTTP requests from clients, generates dynamic web pages, and returns responses
  • Manages requests and responses through HttpServletRequest and HttpServletResponse objects
  • When a web server forwards a request to the WAS, the WAS executes the corresponding servlet, performs the necessary logic, and sends the results to the web browser

JSP (Java Server Pages): Web page generation technology

  • Technology that dynamically generates web pages on the server by embedding Java code within HTML
  • Converted to a Servlet during execution, compiled and run; acts as a template for easily writing Servlets
  • Facilitates the creation of complex web pages and enables database integration, session management, etc.
  • Executable on WAS

WAS (Web Application Server)

  • Middleware providing the execution environment for web applications
    Processes dynamic web content
  • While web servers handle static resources (HTML, images, etc.), WAS handles dynamic requests like database integration, session management, and business logic processing
  • Representative WAS: Tomcat, IBM WebSphere

--

--