Languages

Install Java (JDK 21)

The Java 21 long-term-support JDK (Eclipse Temurin), with JAVA_HOME set.

  1. Install the JDK
    Terminal
    brew install --cask temurin@21
  2. Set JAVA_HOME for new terminals
    Terminal
    echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 21)' >> ~/.zshrc
    source ~/.zshrc

Check it worked

  1. Check the versions
    Terminal
    java -version && javac -version && echo $JAVA_HOME
Undo it
  1. Uninstall the JDK
    Terminal
    brew uninstall --cask temurin@21
  1. Install the JDKNeeds sudo
    Terminal · Ubuntu / Debian
    sudo apt install -y openjdk-21-jdk
  2. Set JAVA_HOME for new terminals
    Terminal · Ubuntu / Debian
    echo 'export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))' >> ~/.bashrc
    source ~/.bashrc

Check it worked

  1. Check the versions
    Terminal · Ubuntu / Debian
    java -version && javac -version && echo $JAVA_HOME
Undo it
  1. Uninstall the JDKNeeds sudo
    Terminal · Ubuntu / Debian
    sudo apt remove -y openjdk-21-jdk
  1. Install the JDK
    PowerShell
    winget install EclipseAdoptium.Temurin.21.JDK

    It sets JAVA_HOME and PATH for you. Close and reopen PowerShell afterwards.

Check it worked

  1. Check the versions
    PowerShell
    java -version; javac -version; $env:JAVA_HOME
Undo it
  1. Uninstall the JDK
    PowerShell
    winget uninstall EclipseAdoptium.Temurin.21.JDK