An Opinionated Guide To Getting Started With Jakarta EE Development in 2023

Photo of Luqman Saeed by Luqman Saeed

This post is inspired by Gunnar Morling'sposton a similar theme for the Java SE Platform. It is an opinionated guide to getting started developing applications on the Jakarta EE Platform. As an opinionated post, there may be some recommendations that you disagree with. That is natural. The post is directed at people just getting started and feel overwhelmed by all the options out there for getting started with enterprise Java. The post is broken down into the following sections;

  • The Theory
  • Java Distro
  • Java Version
  • Build Tool
  • IDE
  • Jakarta EE Version
  • Jakarta EE Runtime
  • Development Workflow
  • Testing
  • Quick Start Template

The Theory Of Jakarta EE

TheJakarta EEplatform has gone through a number of transitions and iterations culminating in its present home at theEclipse Foundation. As a result, it has a a lot of theories and history that are important to know in order to appreciate the current nature, structure, community and decision making style of the project. For all the FAQs about the platform, take a look atthis post.

Java Distro

As a Java based development platform, Jakarta EE requires the JDK available on your machine. Java releases a new version every 6 months, with an LTS every two years. As a Java developer, you might have need for different versions on your local machine for development purposes. To help manage the different installations, I recommend your checkoutSDKManif you've not done so yet.

SDKMan helps you install different versions of Java and many other Java libraries and frameworks in an easy to manage way. With this tool, you can have different versions of Java on your local machine and easily set which is the default version with a single command. 

For the Java distro, I recommend theAzul Zulubuilds of the OpenJDK. You can easily find the various available builds with SDKMan by typing

sdk list java

You can then install the latest Zulu build of Java 19 with

sdk install java  19.0.2-zulu 

After downloading, SDKMan will ask if you wish to set this newly downloaded Java distribution as the default. Accept yes and then you now have the latest Java 19 Azul OpenJDK build installed.

Java Version

The latest LTS release of Java is 17. For developing with Jakarta EE, this is the version you should set as the source and target.

Build Tool

For build tool, Maven is the defacto choice for development on the Jakarta EE Platform. And that is what I recommend. You can also install the latest release of Maven through SDKMan with the command

sdk install maven

This will install the latest release of Maven, at the time of this written, version 3.8.7 and give you the option of setting it as default. 

Integrated Development Environment

There are a number of good IDEs for developing on the Jakarta EE Platform. My first choice recommendation is to useJetBrains IntelliJ if you have a license. If not, the second best recommendation is to useApache NetBeans. Both IDEs have excellent support for Jakarta EE development without requiring you to do a lot of plumbing setup. Simply install either of these and get productive with Jakarta EE out of the box.

Jakarta EE Version

The latest (and greatest) release of theJakarta EE Platform is version 10, released in September 2022. This is the version you should use for all new applications. 

Jakarta EE Runtime

There are differentcompatible runtimes or implementations (or as come call it, application servers) out there that support running Jakarta EE applications, some with commercial support for your production runtimes. My recommendation for a runtime is naturally the Payara Platform. You can start immediately with thePayara Platform Community stream and when you are ready for production, get Payara Platform Enterprise

Development Workflow

The typical development workflow for Jakarta EE applications is no different from that of any other development process. You write code that solves your business problem, deploy it, do a quick test, add or remove code, redeploy and generally just repeat the process. Jakarta EE application development is the same. You write your code, deploy it to Payara runtime, test it, and keep repeating until done. 

With the advent of containers, this whole process can be simplified by through the use of Docker. Payara comes with a feature called auto-deploy, where it has a special folder as part of its installation, that it scans continuously. Any .war file you drop in that folder automatically gets deployed. With this, you can deploy a Payara container and mount the auto-deploy folder to a local folder within which you package and drop you application .war file. 

A typical Payara entry in a docker-compose file will be something as follows

  app:
    image: jee/jumpstart:latest
    volumes:
      - ./deployments:/opt/payara/appserver/glassfish/domains/domain1/autodeploy
    ports:
      - "8080:8080"
      - "4848:4848"
      - "9009:9009"
    depends_on:
      - mysql
    healthcheck:
      test: curl --fail http://localhost:8080/health/ready || exit 1
    build:
      context: .
      dockerfile: Dockerfile

Where /deployments is a folder on the host bound to the auto-deploy folder in the container. With this setup, continuously redeploying the application is as simple as typing

mvn clean package -DskipTests && cp -rf target/*.war deployments 

Testing

There are different testing options on the Jakarta EE Platform for creating both unit and integration tests. As a Java based development platform, you should use the ubiquitousJUnit.TheMockito framework can also be employed to help mock complex objects to allow testing application components in isolation. For integration testing, I recommend you check out theTestcontainers project. This is a Java library that allows you to deploy your application in Docker containers in a test context against which you can make test assertions. There is also the Arquillian project, but it isn't something I'd recommend as a first choice as the setup can be quite steep and take time for starters. Take a look athis testing guide for all the testing options available to you on the Jakarta EE Platform. 

Quick Start Template

I've put all of the above recommendations together into aquick start template you can clone from our GitHub organisation to get started developing on the Jakarta EE platform. Check it out, get started and happy Jakarta EE hacking!

Want to read more about Jakarta EE first? Try some of our guides:

Comments