Get started with Java versions and IntelliJ
A quick start for LAA engineers who need to install Java, manage multiple JDKs, and get IntelliJ licensed. The steps assume macOS, which is standard for MoJ laptops.
Pick a JDK version
- Default to Amazon Corretto latest LTS (currently Java 21) unless the service says otherwise; Corretto is the LAA base in containers (
amazoncorretto:25-alpine). - Java is backward compatible, so prefer the latest LTS unless the service pins an older one.
- Check the repository for
.sdkmanrc,.java-version,Dockerfile, or build files that specify the expected JDK. - Keep multiple LTS versions handy if you work across services; we often support both 17 and 21 during migrations.
Option 1: install via IntelliJ IDEA
- Download IntelliJ IDEA (Community to start; Ultimate once you have a license): https://www.jetbrains.com/idea/download/?section=mac.
- Request an Ultimate license in Slack
#laa-digital-business-supportwith your MoJ email and laptop hostname; approvals are usually quick. - In IntelliJ, open
File > Project Structure > SDKs > + > Download JDK, choose vendor Amazon Corretto and version 21 (add 17 if needed), then set it as the Project SDK. - If you also use jenv, add the downloaded JDK path (see below) so command-line builds match IntelliJ.
Option 2: install via SDKMAN!
- Install SDKMAN:
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
- Install JDKs:
sdk list java | grep -i amzn # note the latest Amazon Corretto IDs (for example 21.0.x-amzn)
sdk install java 21.0.x-amzn # replace x with the latest 21 ID you saw
sdk install java 17.0.x-amzn # also install 17 if you need it
- Set a default:
sdk default java 21.0.x-amzn
- Use per-project versions inside a repo that has
.sdkmanrc:
sdk env install
sdk env
Manage multiple JDKs with jenv (recommended)
Jenv makes switching versions seamless across shells and build tools, regardless of whether the JDKs came from IntelliJ, SDKMAN, or another installer.
- Install jenv:
brew install jenv
- Add to your shell: append the line below to
~/.zshrcor~/.bashrc, then restart your shell.
eval "$(jenv init -)"
- Enable PATH export once:
jenv enable-plugin export
- Add the JDKs you installed (adjust paths/versions to match what you installed):
jenv add ~/.sdkman/candidates/java/21.0.*/ # Amazon Corretto 21 from SDKMAN
jenv add ~/.sdkman/candidates/java/17.0.*/ # Amazon Corretto 17 from SDKMAN
jenv add /Library/Java/JavaVirtualMachines/<name>/Contents/Home # Amazon Corretto downloaded by IntelliJ or another installer
- Pick versions (use the exact versions shown by
jenv versions):
jenv global 21.0.x # sets your global default
jenv local 17.0.x # writes .java-version in the current project
jenv versions # list what jenv knows about
Verify your setup
- Check the active JDK and where it comes from:
java -version
jenv which java
- Check jenv integration:
jenv doctor
- Confirm your build uses the expected JDK:
./gradlew --version