- Install the JDK
brew install --cask temurin@21 - Set JAVA_HOME for new terminals
echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 21)' >> ~/.zshrc source ~/.zshrc
Check it worked
- Check the versions
java -version && javac -version && echo $JAVA_HOME
Undo it
- Uninstall the JDK
brew uninstall --cask temurin@21
- Install the JDKNeeds sudo
sudo apt install -y openjdk-21-jdk - Set JAVA_HOME for new terminals
echo 'export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))' >> ~/.bashrc source ~/.bashrc
Check it worked
- Check the versions
java -version && javac -version && echo $JAVA_HOME
Undo it
- Uninstall the JDKNeeds sudo
sudo apt remove -y openjdk-21-jdk
- Install the JDK
winget install EclipseAdoptium.Temurin.21.JDKIt sets JAVA_HOME and PATH for you. Close and reopen PowerShell afterwards.
Check it worked
- Check the versions
java -version; javac -version; $env:JAVA_HOME
Undo it
- Uninstall the JDK
winget uninstall EclipseAdoptium.Temurin.21.JDK