1. Open the terminal
/usr/libexec/java_home -V
Copy the code
2. View the current Java version
java -version
Copy the code
3. Switch to JDk1.8
Export JAVA_HOME = ` / usr/libexec / 1.8 ` JAVA_HOME - vCopy the code
4. Set it to the default JDK version (optional)
Open ~/. Bash_profile # SWITCH TO JAVA VERSION 8 export JAVA_HOME= '/usr/libexec/ JAVA_HOME -v 1.8'Copy the code
5. Update the configuration
source .~/.bash_profile
Copy the code
6. View the Java version