Prerequisites for a Java 21 & Spring Boot 3 Project

This post links to: Building a Spring Boot CRUD App With Postgres from Scratch: The Complete Guide.

ToolWhat It’s ForRecommended Version
Java JDKRun Spring BootJDK 21+
IDEWrite and navigate Java codeIntelliJ IDEA
GitVersion controlLatest
PostmanTest REST APIsAny

The following are some prerequisites needed to start building a Spring Boot Project with Java 21.

Java

MacOS

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install Java with Homebrew

brew install openjdk@21 

Add Java to your shell/terminal

echo 'export PATH="/opt/homebrew/opt/openjdk@21/bin:$PATH"' >> ~/.zprofile

In the terminal check to see if Java is installed

java --version

You should see a similar output: openjdk 21.0.5 2024-10-15 LTS

Windows

Download the latest Open JDK 21 from Temurin -> https://adoptium.net/en-GB/temurin/releases. (Temurin is just a flavour of Open JDK to run Java 21)

Follow the Windows installer guide -> https://adoptium.net/en-GB/installation/windows

Check in the terminal to see if Java is installed

java --version

You should see a similar output: openjdk 21.0.5 2024-10-15 LTS

IDE - IntelliJ IDEA

Usually it is a good idea to have an integrated development environment (IDE) to edit and run a Spring Boot/Java project. My recommendation would be to use IntelliJ IDEA Community Edition as it's free and has good support for Java/Spring. This will be the chosen IDE throughout this blog.

Docker

Docker will be used throughout this blog to run applications or other dependencies such as databases.

Docker Desktop can be installed for both macOS and Windows.

MacOS

  1. Go to the Docker Desktop download page: https://www.docker.com/products/docker-desktop/
  2. Click “Download for Mac” based on your chip: Apple Silicon (M1/M2/M3) or Intel
  3. Open the .dmg file and drag Docker to the Applications folder.
  4. Launch Docker Desktop and grant any required permissions.
  5. Wait for Docker to start (look for the 🐳 icon in the menu bar).
  6. Verify the installation on the terminal:
docker --version

Windows

  1. Visit: https://www.docker.com/products/docker-desktop/
  2. Click “Download for Windows” and run the installer.
  3. Follow the setup instructions:
    • If prompted, install the WSL2 backend. You may need to restart your computer.
  4. Once Docker Desktop is installed, launch it and wait for it to initialize.
  5. Test the installation:

Open Command Prompt or PowerShell and run:

docker --version

Git

Git is a version control system designed to track changes in code for software development. This will be helpful if you want to use GitHub to clone any example repositories from this blog.

MacOS

Git should already be downloaded along with Xcode by default.

You can check by running the following in the terminal:

git -v

You should see an output something like: git version 2.39.5 (Apple Git-154)

If not, you can install it through Homebrew and re-run the previous command to check it's installed:

brew install git

Windows

Git can be installed here.

Follow the installer instructions.

Then run the following check to verify installation:

git -v

You should see an output something like: git version 2.42.0.windows.1

Postman

Postman is a tool which we can use to test our API endpoints that we will expose from our Spring Boot application. These API endpoints will be how we communicate with the app.

Click here to download Postman for your operating system.