Change the default Java Version on macOS

When we have installed more than one Java version in macOS and want to work with another JDK, changing the Java version is straightforward, but changes will be saved or reflected until the Terminal is opened. It will show the default Java version when you have closed the terminal and opened it again. so it’s essential to set the default java version if you want to reflect it permanently. how to change the java version on Mac

Open a new Terminal window and type “/usr/libexec/java_home -V” to show all Java Versions.

List of java version

 

Open the terminal and use the command “~/.bash_profile”

#SWITCH TO JAVA VERSION 11
export JAVA_HOME=`/usr/libexec/java_home -v 11.0`

Save and close the file. You can try to reopen the terminal and check the default Java -Version

Leave a Comment

Your email address will not be published. Required fields are marked *