-
Verify the default Java version in terminal by running the command:
java -version
-
Download the appropriate JDK from Oracle website for Mac OS
-
After installation completes,
cd
into/usr/libexec
from a terminal window -
From the
libexec
directory, verify all installed Java versions by running the command:./java_home -V
-
Open your shell config file
- zsh & vscode users, run:
code ~/.zshrc
- bash & vscode users, run:
code ~/.bash_profile
- zsh & vscode users, run:
-
Paste the following in the file:
export JAVA_HOME=$(/usr/libexec/java_home -v version_of_your_java)
- Replace the
version_of_your_java
with the JDK version you want to set. For example,java version "1.8.0_171"
will be 1.8.0_171
- Replace the
-
Save the file
- If you are using
zsh
run the commandsource ~/.zshrc
to save changes made to the file
- If you are using
-
Verify the changes by running the command:
java -version
this should be 1.8
Last active
January 16, 2020 00:51
-
-
Save melsoriano/26920869f65af51447f217b282f2e5fd to your computer and use it in GitHub Desktop.
Changing default Java version on Mac OS
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment