Table of Contents
- Check current version
- View all versions on machine
- Download a new version of Java
- Check JAVA_HOME
- Update JAVA_HOME
Check current version
java -version
View all versions on machine
/usr/libexec/java_home -V
Download a new version of Java
Check JAVA_HOME
echo $JAVA_HOME
Update JAVA_HOME
Step one
export JAVA_HOME=`/usr/libexec/java_home -v X.X.X`
// Example
export JAVA_HOME=`/usr/libexec/java_home -v 20.0.02`
Step two
nano ~/.zshrc
/**
* If you don't already have JAVA_HOME defined, add it
* to this file with the path to your desired version of
* Java. Example below:
**/
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home"
Save your changes
CTRL + O (Not zero)
ENTER
CTRL + X
Confirm
// Confirm your file saved
nano ~/.zshrc
// Confirm Java version
java --version
Thank you for reading 🙏🏽 I hope this was helpful. ☺️
Top comments (0)