Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – Black Friday 2026 – NPI EA – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

1. Overview

In this tutorial, we’ll look at the differences between the Java JAR (Java ARchive), WAR (Web Application ARchive) and EAR (Enterprise Application aRchive) artifact files.

We’ll discuss what each file format accomplishes and how to use it.

2. Java Artifact File Formats

The Java specification contains multiple types of artifact files. The most prominent are JAR, WAR, and EAR, but there are others as well. Starting with the JAR, each type builds upon the other, respectively.

Although the JAR file format is part of the JavaSE specification, WAR and EAR files are themselves part of JavaEE, now known as JakartaEE.

3. JAR Files

As we know, the JAR file is the basic artifact for Java applications.

Under the hood, it’s essentially a .zip file with the .jar extension. It includes contents such as classes, resources, and meta information files.

We can create JAR files with the jar program and run them using the java -jar command on any system with just the Java Runtime Environment (JRE) .

4. WAR Files

WAR files are used for bundling Java web applications.

They’re also .zip files under the hood and are an extension of the JAR file format.

Along with classes and resources, WAR files can contain other JARs in the form of libraries, JSP files, Java Servlets, as well as all types of static web files (HTML, CSS, Javascript, etc.).

JakartaEE specifies that correctly-formatted WAR files must contain a WEB-INF directory, which itself contains a web.xml file. This is where we declare the structure and configurations of the web application, such as the web paths of each servlet or the session timeout amount.

In contrast to JARs, WAR files cannot be run as standalone applications and we can only use them as components of another application, like a servlet container or an application server.

The process of putting a WAR file into a server is known as application deployment. Typical Application Servers include Tomcat, Jetty and Wildfly.

5. EAR Files

EAR files are used for enterprise applications composed of multiple modules.

There are multiple types of modules, but the most common are web modules, essentially WAR files, and EJB modules which are special types of JAR files that contain Enterprise Java Bean classes.

Similar to WAR, the EAR is a JAR extension and must contain a special XML file, named application.xml, under a root META-INF directory. In this file, we describe the enterprise application and list its modules. Additionally, we can add security roles for the whole app.

Like WAR, an EAR file also cannot be run as a standalone application. We must deploy it on an application server.

However, in this case, not all types are compatible. We must use a server that supports JakartaEE technologies such as Wildfly, but we can’t use Jetty. As for Tomcat, it’s also incompatible, but there’s a different flavor, named TomEE, which is compatible.

The advantage of the EAR format is that it allows us to specify a complex multi-component application in a single file. Additionally, we can avoid duplication by sharing common resources. Finally, the single file format is very helpful because it eliminates deployment errors.

6. Conclusion

In this article, we looked at the differences between WAR and EAR files. We learned the structure of each file and discussed their typical use cases. Finally, we saw how to use each type of artifact.

Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

Course – Black Friday 2026 – NPI EA – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW