What is Jakarta EE?
Think of Jakarta EE like a professional construction toolkit:
- 🔨 Java SE (Standard Edition) = Basic hammer and nails (core Java)
- 🏗️ Jakarta EE (Enterprise Edition) = Complete construction equipment (power tools, cranes, blueprints)
- 🏢 You use Jakarta EE to build large-scale, enterprise applications
Jakarta EE (formerly Java EE) is a set of specifications that extend Java SE with enterprise features for building large, multi-tier, scalable, reliable, and secure applications.
History: Oracle donated Java EE to the Eclipse Foundation in 2017, and it was renamed to Jakarta EE. Jakarta EE 11 is the latest major release (2024).
Real-World Analogy: Building vs Blueprint
- Specification: Blueprint that says "A door must be 80 inches tall and open/close properly"
- Implementation: Actual door built by a manufacturer (Payara, WildFly, GlassFish)
- Your Application: The house you build using those standardized doors
Why specifications matter: You write code once against the Jakarta EE specifications, and it runs on any compliant server (Payara, WildFly, Liberty, etc.) without changes!
Jakarta EE vs Java SE
| Feature | Java SE (Standard Edition) | Jakarta EE (Enterprise Edition) |
|---|---|---|
| Purpose | General-purpose programming | Enterprise/business applications |
| Includes | Core Java (collections, I/O, threads) | Java SE + Web, persistence, security APIs |
| Application Type | Desktop apps, simple servers | Web apps, REST APIs, microservices |
| APIs | java.*, javax.* | jakarta.* (web, persistence, inject, etc.) |
| Server Required | No (runs on JVM) | Yes (needs application server) |
| Example Use | Calculator app, file processor | Banking system, e-commerce site |
What's New in Jakarta EE 11?
Major Highlights
- ✅ Java SE 21+ Support: Built on Java 21 LTS with modern features
- ✅ Virtual Threads: Lightweight concurrency (Project Loom)
- ✅ CDI 4.1: Enhanced dependency injection with build-time optimizations
- ✅ Servlet 6.1: Improved performance and HTTP/3 preparation
- ✅ JPA 3.2: Better query API and native SQL support
- ✅ REST 4.0: Reactive JAX-RS improvements
- ✅ Security 4.0: Modern authentication mechanisms
Evolution Timeline
Java EE 8 (2017) → Oracle hands over to Eclipse Foundation
↓
Jakarta EE 8 (2019) → Same as Java EE 8, new governance
↓
Jakarta EE 9 (2020) → Namespace change: javax.* → jakarta.*
↓
Jakarta EE 10 (2022) → Java 11+, CDI Lite, modern features
↓
Jakarta EE 11 (2024) → Java 21+, Virtual Threads, performance
Important Change: Jakarta EE 9+ uses jakarta.* packages instead of javax.*
// Old (Java EE / Jakarta EE 8)
import javax.servlet.*;
import javax.persistence.*;
// New (Jakarta EE 9+)
import jakarta.servlet.*;
import jakarta.persistence.*;
Core Jakarta EE Specifications
1. Web Tier
- Servlet 6.1: Handle HTTP requests and responses
- JSP (JavaServer Pages): Dynamic web pages with Java code
- JSF (Faces): Component-based UI framework
- WebSocket 2.1: Real-time bidirectional communication
2. RESTful Web Services
- JAX-RS 4.0: Build REST APIs with annotations
- JSON-B 3.0: JSON binding (Java objects ↔ JSON)
- JSON-P 2.1: JSON processing (parsing/generating)
3. Enterprise Beans
- EJB (Lite): Stateless/Stateful session beans, timers
- Interceptors: Cross-cutting concerns (logging, security)
- Concurrency: Managed threads and executors
4. Persistence
- JPA 3.2: Object-relational mapping (ORM)
- Transactions (JTA): Distributed transaction management
- Bean Validation 3.0: Validate data with annotations
5. Dependency Injection & Context
- CDI 4.1: Contexts and Dependency Injection (core of Jakarta EE)
- Inject: Dependency injection annotations
- Managed Beans: Container-managed objects
6. Security
- Security 4.0: Authentication and authorization
- Authentication: Identity stores, mechanisms
- Authorization: Role-based access control
7. Messaging
- JMS (Messaging): Asynchronous message passing
- Message-Driven Beans: Process messages automatically
Jakarta EE Architecture
Multi-Tier Architecture
┌─────────────────────────────────────────┐
│ Client Tier (Browser) │
│ HTML, CSS, JavaScript, React, Angular │
└─────────────────┬───────────────────────┘
│ HTTP/REST
┌─────────────────▼───────────────────────┐
│ Web Tier (Server) │
│ Servlets, JSP, JSF, JAX-RS, WebSocket │
└─────────────────┬───────────────────────┘
│
┌─────────────────▼───────────────────────┐
│ Business Tier (Server) │
│ EJB, CDI Beans, Business Logic │
└─────────────────┬───────────────────────┘
│
┌─────────────────▼───────────────────────┐
│ Persistence Tier (Database) │
│ JPA, JDBC, Database Access │
└─────────────────────────────────────────┘
Container Services
Jakarta EE servers provide "container services" - features you don't have to implement yourself:
- 🔄 Lifecycle Management: Container creates/destroys beans automatically
- 💉 Dependency Injection: Auto-wire dependencies with @Inject
- 🔒 Transaction Management: Automatic commit/rollback with @Transactional
- 🛡️ Security: Built-in authentication and authorization
- 📦 Resource Management: Connection pooling, thread pools
- ⏱️ Concurrency: Managed thread executors
Simple Jakarta EE Example
Let's build a simple REST API with Jakarta EE:
1. REST Endpoint (JAX-RS)
package com.example;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.*;
import java.util.*;
@Path("/hello") // URL: /api/hello
public class HelloResource {
@GET // Handle GET requests
@Produces(MediaType.TEXT_PLAIN)
public String sayHello() {
return "Hello from Jakarta EE 11!";
}
@GET
@Path("/{name}") // URL: /api/hello/John
@Produces(MediaType.TEXT_PLAIN)
public String sayHelloToName(@PathParam("name") String name) {
return "Hello, " + name + "!";
}
@GET
@Path("/json")
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> getJson() {
return Map.of(
"message", "Hello Jakarta EE!",
"version", 11,
"timestamp", System.currentTimeMillis()
);
}
}
2. Application Configuration
package com.example;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
@ApplicationPath("/api") // Base URL for all REST endpoints
public class RestApplication extends Application {
// No code needed! Just this annotation
}
3. Deploy and Test
# Package as WAR file
mvn clean package
# Deploy to Jakarta EE server (Payara, WildFly, etc.)
# Server automatically detects and configures the application
# Test the endpoints
curl http://localhost:8080/myapp/api/hello
# Output: Hello from Jakarta EE 11!
curl http://localhost:8080/myapp/api/hello/Alice
# Output: Hello, Alice!
curl http://localhost:8080/myapp/api/hello/json
# Output: {"message":"Hello Jakarta EE!","version":11,"timestamp":1704067200000}
What just happened?
- ✅ No manual HTTP handling - JAX-RS does it
- ✅ No manual JSON conversion - JSON-B does it
- ✅ No web server setup - Container provides it
- ✅ Just write business logic with annotations!
Jakarta EE Profiles
Jakarta EE Platform (Full Profile)
- All specifications included
- For traditional enterprise applications
- Best for: Large monolithic apps with all features
Jakarta EE Web Profile
- Subset focused on web applications
- Includes: Servlets, JSP, JSF, JPA, CDI, EJB Lite, Bean Validation, JAX-RS
- Excludes: Full EJB, JMS, JAXB, etc.
- Best for: Modern web apps, REST APIs, microservices
Jakarta EE Core Profile (New in 10)
- Minimal subset for cloud-native applications
- Includes: CDI Lite, JSON-B, JSON-P, REST Client
- Best for: Microservices, serverless, cloud deployment
| Profile | Size | Use Case | Example Server |
|---|---|---|---|
| Full Platform | Large (~200MB+) | Enterprise monoliths | WildFly, Payara |
| Web Profile | Medium (~100MB) | Web apps, REST APIs | TomEE, Payara Micro |
| Core Profile | Small (~30MB) | Microservices, cloud | Helidon, Open Liberty |
Popular Jakarta EE Servers
1. Eclipse GlassFish
- Type: Reference implementation
- Best for: Learning, testing specifications
- License: Open source (Eclipse Foundation)
2. Payara Server
- Type: Production-ready (based on GlassFish)
- Best for: Production deployments, microservices
- Features: Enhanced performance, Docker support
3. WildFly (Red Hat JBoss)
- Type: Full-featured server
- Best for: Large enterprise applications
- Features: Clustering, high availability
4. Open Liberty (IBM)
- Type: Lightweight, modular
- Best for: Cloud-native, microservices
- Features: Fast startup, small footprint
5. Apache TomEE
- Type: Tomcat + Java EE/Jakarta EE
- Best for: Web Profile applications
- Features: Familiar Tomcat + EE features
Getting Started with Jakarta EE 11
Prerequisites
# 1. Java SE 21 or later
java -version # Should show 21+
# 2. Maven or Gradle
mvn -version
# 3. Jakarta EE Server (choose one)
# Download: GlassFish, Payara, WildFly, etc.
Maven Project Setup
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jakarta-ee-app</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<jakarta.ee.version>11.0.0</jakarta.ee.version>
</properties>
<dependencies>
<!-- Jakarta EE 11 API (provided by server) -->
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakarta.ee.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Directory Structure
jakarta-ee-app/
├── pom.xml
└── src/
└── main/
├── java/
│ └── com/example/
│ ├── HelloResource.java
│ └── RestApplication.java
└── webapp/
├── WEB-INF/
│ └── web.xml (optional in Jakarta EE)
└── index.html
Jakarta EE vs Spring Framework
| Aspect | Jakarta EE | Spring Framework |
|---|---|---|
| Type | Specification (standards) | Framework (implementation) |
| Governance | Eclipse Foundation (open) | VMware (company) |
| Server Required | Yes (Jakarta EE server) | No (embedded Tomcat) |
| Dependency Injection | CDI (@Inject) | Spring IoC (@Autowired) |
| REST API | JAX-RS (@Path) | Spring MVC (@RestController) |
| Persistence | JPA (standard) | Spring Data JPA (wrapper) |
| Learning Curve | Moderate (standards-based) | Easier (opinionated) |
| Adoption | Enterprise, government | Startups, modern apps |
| Portability | High (any EE server) | Medium (Spring-specific) |
Which to choose?
- Jakarta EE: Standards-based, vendor-neutral, long-term stability, government/enterprise
- Spring: Quick start, large ecosystem, modern features, community-driven
- Both are valid! Spring actually uses many Jakarta EE specifications (JPA, Servlet, Bean Validation)
Best Practices
✅ DO:
- Use CDI everywhere - It's the backbone of Jakarta EE
- Leverage container services - Let the server manage lifecycle, transactions, security
- Follow specifications - Write portable code that works on any server
- Use annotations - Less XML, more declarative programming
- Start with Web Profile - Most apps don't need Full Profile
- Use JPA for database - Standard ORM solution
- Build REST APIs with JAX-RS - Clean, annotation-based
❌ DON'T:
- Don't manage threads manually - Use @Asynchronous or Managed Executors
- Don't mix Jakarta EE and Spring randomly - Pick one approach
- Don't use Full Profile unless needed - Web Profile is usually enough
- Don't ignore CDI scopes - Understanding scopes is crucial
- Don't write framework code - Use what Jakarta EE provides
Summary
- Jakarta EE is a set of specifications for enterprise Java applications
- Jakarta EE 11 requires Java 21+ and includes modern features like Virtual Threads
- Namespace: Uses
jakarta.*packages (notjavax.*) - Three profiles: Full Platform, Web Profile, Core Profile
- Core technologies: Servlets, JAX-RS, JPA, CDI, EJB, Bean Validation, Security
- Container services: Dependency injection, transactions, security, lifecycle
- Servers: GlassFish, Payara, WildFly, Open Liberty, TomEE
- Benefits: Standards-based, portable, vendor-neutral, enterprise-ready
- Use when: Building scalable enterprise apps with standardized approach