Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 119 ยท Servlets and JSP

Jakarta EE Overview

Understand Jakarta EE - the move from Java EE and javax to jakarta, the main specifications, profiles, servers like Tomcat and WildFly, WAR files and how Spring fits in.

Open the dependency tree of almost any Java web application, including a modern Spring Boot service, and you will find packages named jakarta.servlet, jakarta.persistence and jakarta.validation. They come from Jakarta EE, the set of standard APIs for enterprise Java that grew out of J2EE and Java EE. Even if you never deploy to a classic application server, these standards define the request objects your controllers use, the annotations on your entities and the validation rules on your DTOs.

This lesson gives you the map before the next lessons dive into servlets and JSP: what Jakarta EE is, why everything was renamed from javax to jakarta, which specifications matter, what servers implement them, what a WAR file contains, and how it all relates to Spring. Along the way you will run small programs that show the core ideas: a specification versus its implementation, the namespace migration, the anatomy of a WAR, and what a container does with several applications.

Specifications, not a product

Jakarta EE is not a library you download and call. It is a set of specifications: documents plus Java APIs (mostly interfaces and annotations) plus test suites, developed openly at the Eclipse Foundation. Vendors write implementations, and a server that passes the official compatibility tests (the TCK) may call itself Jakarta EE compatible.

That split lets you write code against standard interfaces and run it on different servers. You already know a JDK API that works exactly this way: JDBC. Your code uses java.sql.Connection and PreparedStatement, which are only interfaces. The H2, PostgreSQL or MySQL driver supplies the classes behind them, found at runtime through the ServiceLoader mechanism.

Java One API, a pluggable implementation

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

Swap the H2 jar for the PostgreSQL driver, change the URL, and the code still works. Jakarta EE applies the same idea to web requests, persistence, dependency injection and more: your servlet extends jakarta.servlet.http.HttpServlet from the API jar, and Tomcat, Jetty or WildFly supply the implementation at runtime.

From J2EE to Jakarta EE

The platform has been renamed twice, which explains the names you will meet in older code and articles:

Year Release What changed
1999 J2EE 1.2 Servlets, JSP, EJB, JDBC extensions; heavy XML configuration
2006 Java EE 5 Annotations instead of XML, EJB 3, the first JPA
2009 Java EE 6 CDI (dependency injection), JAX-RS (REST), the Web Profile
2013 Java EE 7 WebSocket, JSON Processing, Batch, Concurrency Utilities
2017 Java EE 8 Servlet 4.0 (HTTP/2), JSON Binding, Security API. Oracle hands the platform to the Eclipse Foundation
2019 Jakarta EE 8 Same APIs as Java EE 8, still javax.*, now open source under a new name
2020 Jakarta EE 9 The big rename: every javax.* package of the platform becomes jakarta.*
2022 Jakarta EE 10 New Core Profile, Servlet 6.0, Java 11 minimum
2025 Jakarta EE 11 Java 17 minimum, Jakarta Data, Servlet 6.1, Persistence 3.2, records support across specs

Why the rename? Oracle transferred the code and specifications but kept the "Java" trademark, and with it the right to evolve javax packages. To keep developing the APIs, the Eclipse Foundation had to move them to a new namespace. The result was a one-time, project-wide breaking change: Jakarta EE 9 APIs are identical to Jakarta EE 8 except for the package names, and a javax.servlet application doesn't run on a jakarta.servlet server.

The javax to jakarta migration

Migrating mostly means changing imports, but there is a trap: not every javax package moved. Packages that belong to the JDK itself (javax.sql, javax.crypto, javax.net.ssl, javax.swing, javax.xml.parsers, javax.naming and others) stay exactly as they are. Only the packages that came from Java EE are renamed. A blind search-and-replace of javax. breaks your code.

This program is a tiny migration tool that knows the difference:

Java Migrating imports from javax to jakarta

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

Notice the subtle cases. javax.annotation.PostConstruct moved, but javax.annotation.processing is part of the JDK compiler API and stayed. javax.transaction.Transactional moved, but javax.transaction.xa belongs to the JDK and stayed. Real projects don't do this by hand: tools such as OpenRewrite recipes, the Eclipse Transformer, or IntelliJ IDEA's built-in migration refactoring rewrite sources, configuration files (persistence.xml, web.xml namespaces) and even compiled jars.

The rename also split the ecosystem by version. As a rule of thumb: Tomcat 9, Spring Boot 2 and Hibernate 5 use javax; Tomcat 10+, Spring Boot 3+ and Hibernate 6+ use jakarta. You can't mix the two in one application.

The main specifications

Jakarta EE 11 contains about 40 specifications. You don't need all of them; these are the ones Java developers meet most, many of them inside Spring applications too:

Specification Package What it gives you Covered in
Servlet jakarta.servlet Handling HTTP requests and responses Servlets
Pages (JSP) + Expression Language + Tags (JSTL) jakarta.servlet.jsp, jakarta.el HTML templates on the server JavaServer Pages
Persistence (JPA) jakarta.persistence Object-relational mapping ORM and JPA Introduction
Bean Validation jakarta.validation @NotBlank, @Size, @Email constraints Validation and Error Handling
CDI (Contexts and Dependency Injection) jakarta.inject, jakarta.enterprise Dependency injection, scopes, events Dependency Injection
RESTful Web Services (JAX-RS) jakarta.ws.rs @Path, @GET REST endpoints
JSON Processing / JSON Binding jakarta.json, jakarta.json.bind JSON parsing and mapping (the standard alternative to Jackson)
Transactions jakarta.transaction @Transactional, JTA
Faces (JSF) jakarta.faces Component-based web UI
Security, Messaging, Batch, Concurrency, Mail, WebSocket, Data ... Security API, JMS, batch jobs, managed executors, e-mail, WebSocket, repositories

Jakarta Data, new in EE 11, standardizes repository interfaces with generated query methods, similar to Spring Data.

Profiles

Not every application needs every specification, so Jakarta EE defines profiles, subsets that a server can implement:

  • Platform (the full set): everything, including Messaging, Batch, Mail and Enterprise Beans. Implemented by full application servers.
  • Web Profile: what typical web applications need: Servlet, Pages, Faces, CDI, REST, Persistence, Validation, Transactions, Security, JSON and more.
  • Core Profile (since EE 10): a small set for microservices and native compilation: CDI Lite, REST, JSON Processing and Binding, Interceptors, Annotations. MicroProfile, an Eclipse project that adds config, health checks, metrics, fault tolerance and OpenAPI, builds on it. Quarkus and Helidon are well-known MicroProfile runtimes.

Servers and containers

The software that runs a Jakarta EE application is a container or application server. It owns the network port, parses HTTP, manages threads, creates your servlets, injects resources and handles transactions, so your code only implements the parts that are specific to your application.

Server Kind Notes
Apache Tomcat Servlet container The most widely used; Servlet, Pages, EL, WebSocket. Tomcat 10.1 = EE 10, Tomcat 11 = EE 11, Tomcat 9 = javax
Eclipse Jetty Servlet container Lightweight and embeddable; Jetty 12 supports several EE versions side by side
WildFly (Red Hat JBoss EAP) Full platform Uses Undertow for HTTP; commercial support as JBoss EAP
Eclipse GlassFish Full platform Long-time reference implementation
Payara Full platform GlassFish derivative with commercial support
Open Liberty (IBM WebSphere Liberty) Full platform + MicroProfile Modular: enable only the features you use
Apache TomEE Web Profile (and more) Tomcat plus the extra Web Profile specs

A servlet container such as Tomcat implements only the web-tier specs. If you want JPA or CDI on Tomcat, you bring libraries (Hibernate, Weld) inside your application. A full application server provides them all, and your application jar stays small.

To see what a container does, the next example plays one in miniature on the JDK's HttpServer. It "deploys" two independent applications at their own context roots (/shop and /blog), calls their startup and shutdown hooks, and routes each request to the right application, just as Tomcat does with several WAR files.

Java A container hosting two applications

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

/forum has no application, so the JDK server answers 404 itself. Real containers add much more to this picture: a separate class loader per application (so two apps can use different library versions), a thread pool, sessions, security realms, JNDI resources such as shared DataSources, and hot redeployment.

WAR files

A Jakarta EE web application is packaged as a WAR (Web Application Archive): a ZIP file with a fixed layout. You copy shop.war into Tomcat's webapps folder, and Tomcat unpacks it and serves it at /shop.

TEXT
shop.war
โ”œโ”€โ”€ index.html                    โ† public static files (served as-is)
โ”œโ”€โ”€ css/site.css
โ”œโ”€โ”€ META-INF/
โ”‚   โ””โ”€โ”€ MANIFEST.MF
โ””โ”€โ”€ WEB-INF/                      โ† never served directly to browsers
    โ”œโ”€โ”€ web.xml                   โ† optional deployment descriptor
    โ”œโ”€โ”€ classes/                  โ† your compiled classes and resources
    โ”‚   โ””โ”€โ”€ com/example/shop/CartServlet.class
    โ””โ”€โ”€ lib/                      โ† jar dependencies bundled with the app
        โ””โ”€โ”€ jackson-databind-2.22.0.jar

Everything outside WEB-INF can be requested by URL; everything inside is private to the application. Because a WAR is just a ZIP, the JDK's java.util.zip can build and inspect one:

Java A WAR is a ZIP with a known layout

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

You rarely build WARs by hand. Maven does it with <packaging>war</packaging>, and the API dependency gets the provided scope: you compile against it, but the server supplies it at runtime, so it must not be copied into WEB-INF/lib.

XML
<packaging>war</packaging>

<dependencies>
  <!-- Whole platform API (or jakarta.servlet:jakarta.servlet-api for servlets only) -->
  <dependency>
    <groupId>jakarta.platform</groupId>
    <artifactId>jakarta.jakartaee-api</artifactId>
    <version>11.0.0</version>
    <scope>provided</scope>
  </dependency>
</dependencies>

An EAR (Enterprise Archive) bundles several WARs and EJB jars for full application servers; it is rare in new projects.

Where Jakarta EE fits next to Spring

Spring started in 2003 as a lighter alternative to the J2EE of that time, which was dominated by heavyweight EJBs and XML. Today the relationship is cooperative rather than competitive:

  • Spring builds on Jakarta EE APIs. Spring MVC runs on the Servlet API, Spring Data JPA uses Jakarta Persistence, and validation uses Jakarta Bean Validation. Spring Framework 6 and Spring Boot 3 moved to the jakarta namespace; Spring Framework 7 and Spring Boot 4 build on Jakarta EE 11.
  • Spring replaces some specs with its own. Spring's dependency injection plays the role of CDI, Spring MVC or WebFlux the role of JAX-RS and Faces, and Spring Security the role of Jakarta Security.
  • Deployment is inverted. In classic Jakarta EE you deploy a WAR into a running server. Spring Boot puts the server (embedded Tomcat or Jetty) inside your application as a library, and you run a single executable jar. Jakarta EE runtimes have adopted that model too: Open Liberty, Payara Micro, WildFly Bootable JAR, Quarkus and Helidon all produce runnable jars.

In practice, you will meet Jakarta EE in three ways: as the APIs inside Spring applications, as classic WAR applications on Tomcat or WildFly in many established companies, and as MicroProfile-based microservices. The servlet model underneath all of them is the subject of the next lessons.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Why did Jakarta EE 9 rename javax.servlet to jakarta.servlet?

    Oracle transferred the code but not the right to change javax packages. EE 9 APIs are otherwise identical to EE 8.
  2. 2. A migration script replaces every javax. import with jakarta.. Which import does it break?

    javax.sql belongs to the JDK and didn't move. Only packages that came from Java EE were renamed.
  3. 3. In a WAR file, which path can a browser request directly?

    Everything outside WEB-INF is public content. WEB-INF holds configuration, classes and libraries and is never served directly.
  4. 4. Why does the Jakarta EE API dependency use Maven's provided scope in a WAR project?

    Bundling the API jar can clash with the server's own copy. Provided means compile against it, but don't package it.
  5. 5. What is the main deployment difference between classic Jakarta EE and Spring Boot?

    Spring Boot ships Tomcat or Jetty as a library inside your application. Modern Jakarta EE runtimes offer runnable jars too.

Summary

  • Jakarta EE is a set of specifications (APIs plus compatibility tests) for enterprise Java; servers and libraries implement them, just as JDBC drivers implement java.sql.
  • J2EE became Java EE, then moved to the Eclipse Foundation as Jakarta EE. EE 9 renamed javax.* to jakarta.*; EE 10 added the Core Profile; EE 11 requires Java 17 and adds Jakarta Data.
  • Only Java EE packages moved. JDK packages like javax.sql, javax.crypto and javax.net.ssl stay. Use OpenRewrite, the Eclipse Transformer or IDE refactorings to migrate.
  • Key specs: Servlet, Pages, Persistence, Bean Validation, CDI, REST, JSON-P/B, Transactions, Faces.
  • Profiles: Platform, Web Profile and Core Profile (the basis of MicroProfile).
  • Servlet containers (Tomcat, Jetty) implement the web tier; application servers (WildFly, GlassFish, Payara, Open Liberty) implement the whole platform.
  • A WAR is a ZIP: public files at the root, private WEB-INF/ with web.xml, classes/ and lib/; use provided scope for the API.
  • Spring builds on many Jakarta EE APIs, replaces others, and embeds the server instead of deploying into one.

Next: Servlets shows the API at the heart of every Java web framework: HttpServlet, doGet and doPost, and the request and response objects.