Jakarta EE8, EE9, EE9.1, …. What???

Jakarta EE is the new Java Enterprise platform as you’ve probably heard. There is a lot of news about this application development framework and also about the rapid development of the platform. Version 9.1 was released in May last year, and version 10 is already under review. But what does this mean for my Java project? Because I was a bit confused about the different versions hence my attempt to clear things up.

item picture

First, the good news: As an app developer, you don’t have to worry. The most important thing that will change besides the improved support by the community is the Java package names. Package name javax.* will be replaced by jakarta.*.

Jakarta EE8

Jakarta EE8 was the first release after the project was overtaken by Eclipse from Oracle. Nothing has changed but the name. Existing Java EE8 projects will work out of the box. In your Maven dependencies, you can now use the new Jakarta EE8 platform reference.

    <dependency>
        <groupId>jakarta.platform</groupId>
        <artifactId>jakarta.jakartaee-api</artifactId>
        <version>8.0.0</version>
        <scope>provided</scope>
    </dependency>
        

Jakarta EE9

The Jakarta EE9 project is something you can generally ignore as an application developer. The goal of Jakarta EE 9 was to change the namespace from javax.* to jakarta.*. It’s more intermediate release, so tools and libraries can get their support for the Jakarta namespace. *. Just in case you want to test your code against the new namespace, changing the release version is appropriate. You just need to change your Maven dependency.

    <dependency>
        <groupId>jakarta.platform</groupId>
        <artifactId>jakarta.jakartaee-api</artifactId>
        <version>9.0.0</version>
        <scope>provided</scope>
    </dependency>

But for normal application development, Jakarta EE9 does not bring any special changes. Since changing the namespace behind the scenes is quite complex, this release was a must for platform and library developers.

By the way, most application servers will migrate the namespace for you during deployment. So, as an app developer, you can still use javax namespaces. *, even if the target runtime is Jakarta EE9. This means that your “legacy” app is using the javax namespace. * It will work fine on newer Jakarta EE servers.

/* Jakarta EE8 */
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("api")
public class BaseApplication extends Application {

}

On the other hand, if you want to try to develop against the new jakarta. * The namespace changes your code as follows:

/* Jakarta EE9 */
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

@ApplicationPath("api")
public class BaseApplication extends Application {

}

Noticeable: Applications that use the . extension jakarta.* The namespace will only work on fully compliant Jakarta EE9 servers (eg wildfly-preview-26.0.0). Most of the official Jakarta EE servers are still located in Jakarta EE 8. So from an application developer’s perspective, it doesn’t currently make sense to switch to the new namespace.

Jakarta EE9.1

The Jakarta EE9.1 project is similar to the Jakarta EE9 project as just an intermediate version. The difference between Jakarta EE 9 and 9.1 is the support for JDK 11. There weren’t supposed to be two versions, but the Jakarta EE project ran out of time to support TCK JDK 11. So, this has been moved to an additional version now known as 9.1.

So again, as an app developer, you can ignore these details. You must force your Maven dependency on JDK 11 in case you want to build against Jakarta EE 9.1:

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependency>
        <groupId>jakarta.platform</groupId>
        <artifactId>jakarta.jakartaee-api</artifactId>
        <version>9.1.0</version>
        <scope>provided</scope>
    </dependency>

Jakarta EE10

So Jakarta EE 9 was released to prepare projects (mostly from vendors of libraries and tools) to change the namespace. As an app developer you can go ahead with the old javax namespace. * (which I currently recommend). Jakarta EE 10 will then become the first version to switch the namespace of all built-in libraries. This means that if Jakarta EE10 is out, you can safely switch your application from javax.* namespace to jakarta.* namespace. But at the moment there is no official server available, you can wait with this.

Switch Namespace

If you plan to switch the namespace later for your project to Jakarta. * Read my blog post. You can simply run a bash script against your source code like this:

#!/bin/bash

# this script can be used to replace deprecated javax. package names from a 
# Java EE8 project with the new jakarta. package names in Jakarta 9
# Initial version from rsoika, 2021

echo "replacing:"
echo "    javax.annotation.  -> jakarta.annotation."
echo "    javax.ejb.         -> jakarta.ejb."
echo "    javax.enterprise.  -> jakarta.enterprise."
echo "    javax.faces.       -> jakarta.faces."
echo "    javax.inject.      -> jakarta.inject."
echo "    javax.persistence. -> jakarta.persistence."
echo "    javax.ws.          -> jakarta.ws."
echo "Replacing now..."

###################
## REPLACE LOGIC ##
###################

# replace package names...
find * -name '*.java' | xargs perl -pi -e "s/javax.annotation./jakarta.annotation./g"
find * -name '*.java' | xargs perl -pi -e "s/javax.ejb./jakarta.ejb./g"
find * -name '*.java' | xargs perl -pi -e "s/javax.enterprise./jakarta.enterprise./g"
find * -name '*.java' | xargs perl -pi -e "s/javax.faces./jakarta.faces./g"
find * -name '*.java' | xargs perl -pi -e "s/javax.inject./jakarta.inject./g"
find * -name '*.java' | xargs perl -pi -e "s/javax.persistence./jakarta.persistence./g"
find * -name '*.java' | xargs perl -pi -e "s/javax.ws./jakarta.ws./g"

echo "DONE!"

.

Leave a Comment