Java Enterprise Edition (Jakarta EE), formerly known as Java EE (Java Platform, Enterprise Edition), is a collection of APIs and runtime environments for developing and running large-scale, distributed, and multi-tiered enterprise applications. Jakarta EE is a set of specifications that define how Java developers should write web applications, microservices, and other large-scale applications.
The transition from Java EE to Jakarta EE happened after Oracle moved the stewardship of Java EE to the Eclipse Foundation, which renamed it to Jakarta EE starting with version 9.0. Jakarta EE builds on the strong foundation of Java EE, introducing new features and evolving to meet modern development requirements.
1. Key Features of Jakarta EE
Jakarta EE provides various technologies that aid in the development of robust, scalable, and secure enterprise applications. These include:
1.1. Servlet API
The Servlet API is a crucial part of Jakarta EE and allows developers to create dynamic web applications. It defines the classes and methods used to interact with HTTP requests and responses, enabling you to create web applications that respond to client requests.
1.2. JavaServer Pages (JSP)
JSP is a technology used to develop dynamic web pages with Java. Jakarta EE supports JSP for generating HTML, XML, or other types of documents in response to client requests.
1.3. Enterprise JavaBeans (EJB)
EJB is a server-side component architecture used to develop business logic in a distributed environment. EJB provides a reliable, secure, and scalable way to handle transaction management, concurrency, and security concerns.
1.4. Contexts and Dependency Injection (CDI)
CDI is a set of services for dependency injection and the management of object lifecycle, allowing you to inject objects where needed, manage their lifecycle, and set up cross-cutting concerns like transactions and security.
1.5. Java Message Service (JMS)
JMS is a messaging standard that enables Java applications to send and receive messages asynchronously. It is used for building loosely coupled, reliable, and scalable distributed systems.
1.6. Java Persistence API (JPA)
JPA simplifies database interaction by allowing you to map Java objects to database tables. It abstracts away the complexity of low-level SQL code and provides a standard way of handling database interactions in Java-based applications.
1.7. Java API for RESTful Web Services (JAX-RS)
JAX-RS enables you to create RESTful web services, a key technology for developing microservices and distributed applications in Jakarta EE. It makes it easier to build HTTP-based APIs by defining annotations for resources, HTTP methods, and responses.
1.8. Java Transaction API (JTA)
JTA provides a way to manage transactions across multiple transactional resources, ensuring consistency in distributed systems.
1.9. Java Authentication and Authorization Service (JAAS)
JAAS provides a standard framework for authenticating and authorizing users in Jakarta EE applications. It supports both username/password-based authentication and more complex, role-based security models.
2. Key Differences Between Jakarta EE and Java EE
While Jakarta EE builds on the foundation of Java EE, there are important changes introduced as part of the transition. These changes are primarily related to the naming and governance, but there are some technical differences as well.
2.1. Transition from Java EE to Jakarta EE
- Branding and Ownership: The Java EE name was owned by Oracle. In 2017, Oracle donated Java EE to the Eclipse Foundation, and it was rebranded as Jakarta EE.
- Package Naming Change: The most visible change in Jakarta EE is the transition of package names from
javax.*
tojakarta.*
. This affects various libraries such asjavax.persistence
tojakarta.persistence
. For example:- Java EE:
javax.persistence.Entity
- Jakarta EE:
jakarta.persistence.Entity
- Java EE:
2.2. New Features in Jakarta EE
Jakarta EE has added several modern features and updates, including:
- MicroProfile Integration: Jakarta EE now embraces MicroProfile, which is a set of technologies for building microservices. MicroProfile offers features like health checks, metrics, fault tolerance, and more.
- Reactive Programming: Jakarta EE 9 and beyond support reactive programming models, making it easier to build event-driven and asynchronous applications.
- Improved Compatibility: Jakarta EE aims to provide better backward compatibility, although the package renaming change was a significant step that required updates to existing Java EE applications.
3. Jakarta EE vs. Other Enterprise Frameworks
Jakarta EE competes with other enterprise frameworks, such as Spring Boot and Micronaut, but it has some distinct advantages and use cases.
3.1. Jakarta EE vs. Spring Boot
- Spring Boot is a popular framework for building microservices and web applications. While Spring Boot is more lightweight and developer-friendly, Jakarta EE is often preferred for larger, more traditional enterprise applications, especially when there’s a need for high-level standards and frameworks.
- Jakarta EE provides standardized components that work across various implementations (e.g., Payara, WildFly, Open Liberty). On the other hand, Spring Boot has its own ecosystem and is seen as more flexible and developer-friendly.
3.2. Jakarta EE vs. Micronaut
- Micronaut is another framework focused on building microservices with a low memory footprint and fast startup time. Micronaut is more modern and optimized for cloud-native and serverless applications. In contrast, Jakarta EE is often used in more traditional enterprise contexts, though it is evolving with features like reactive programming and microservices support.
4. Using Jakarta EE with Spring Boot
While Spring Boot is a popular choice for microservices and cloud-native applications, Jakarta EE can also be used with Spring Boot for more traditional enterprise applications. You can run Jakarta EE components inside Spring Boot using Spring Boot’s Jakarta EE support, which is achieved through integrating libraries and APIs such as JAX-RS, JPA, and CDI.
5. Example: Simple Jakarta EE Application
Here’s an example of a simple Jakarta EE REST API using JAX-RS (Java API for RESTful Web Services):
5.1. Dependencies (Maven)
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.29.1</version>
</dependency>
5.2. REST Resource
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@Path("/hello")
public class HelloResource {
@GET
public String sayHello() {
return "Hello, Jakarta EE!";
}
}
5.3. Application Class
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
@ApplicationPath("/api")
public class MyApplication extends Application {
}
In this example:
- A simple RESTful API is created with Jakarta EE using the JAX-RS API.
- The application listens at
/api/hello
and returns a greeting message.