Fill these in once
- List the Java versions you have
/usr/libexec/java_home -V - Use one by default
echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 21)' >> ~/.zshrc source ~/.zshrc
Check it worked
- Check the version
java -version
- Pick the default Java from a listNeeds sudo
sudo update-alternatives --config javaType the number of the version you want.
Check it worked
- Check the version
java -version
- List the Java versions you have
Get-ChildItem "C:\Program Files\Eclipse Adoptium" - Point JAVA_HOME at the one you want
[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Eclipse Adoptium\jdk-21", "User")Close and reopen PowerShell afterwards.
Check it worked
- Check JAVA_HOME
$env:JAVA_HOME