Dec 8, 2020

Installing JDK on MacOS

Check the version of JDK installed and the path on your MacOS

/usr/libexec/java_home -V

Check this instance/version of the JDK is currently running on your MacOS

java --version

The above command will show the currently used JDK and JRE


If you have multiple instances of JDK installed on your MacOS and want to switch the version based on the required environment. You can do so by following the below steps:

Edit ~/.bash_profile and set JAVA_HOME environment variable

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

In case of MacOS BigSur

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0) 

The above command will switch the JDK version to 1.8

Reload the changes to the environment

source ~/.bash_profile


No comments:

Post a Comment