Java SDK & Maven Setup

Download and install OpenJDK 21 (LTS), install Maven 3.9, set JAVA_HOME correctly, and verify both tools are on the PATH.

Java SDK & Maven Setup

CAP Java projects run on Spring Boot and require Java 17 or 21 (LTS).

Install Java 21 (OpenJDK)

macOS — using Homebrew

brew install openjdk@21
# Follow the caveats to add to PATH:
echo 'export PATH="/opt/homebrew/opt/openjdk@21/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Windows — using the installer

  1. Download from adoptium.net — select JDK 21, Windows, x64
  2. Run the .msi installer — check Set JAVA_HOME in the optional features

Linux (Ubuntu/Debian)

sudo apt install openjdk-21-jdk

Verify

java --version
# openjdk 21.x.x

javac --version
# javac 21.x.x

Set JAVA_HOME (if not set automatically)

macOS / Linux — add to ~/.zshrc or ~/.bashrc

export JAVA_HOME=$(/usr/libexec/java_home -v 21)   # macOS
# or
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64  # Linux

export PATH=$JAVA_HOME/bin:$PATH

Reload: source ~/.zshrc

Windows — System Environment Variables

  1. Search for Environment Variables in Start
  2. Under System Variables → New:
  3. Name: JAVA_HOME
  4. Value: C:\Program Files\Eclipse Adoptium\jdk-21.x.x.x-hotspot
  5. Edit Path → Add %JAVA_HOME%in

Install Maven 3.9

macOS

brew install maven

Linux

sudo apt install maven

Windows

Download from maven.apache.org → unzip → add bin/ to PATH.

Verify

mvn --version
# Apache Maven 3.9.x
# Java version: 21.x.x

Make sure Maven reports the correct Java version. If it shows Java 11 or 17, your JAVA_HOME isn't set for Maven.

Sign in for progress tracking & Q&A →