Skip to content

Instantly share code, notes, and snippets.

@spdeepak
Last active September 18, 2018 07:57
Show Gist options
  • Save spdeepak/63f5cf068454ef64b2028a1011fd0aaf to your computer and use it in GitHub Desktop.
Save spdeepak/63f5cf068454ef64b2028a1011fd0aaf to your computer and use it in GitHub Desktop.
How to set JAVA_HOME on mac

Use the below command to see the version of the JDK installed

/usr/libexec/java_home -V

OR

java -version

Open .bash_profile

vim .bash_profile

Write the following to the .bash_profile (For default JDK 8 or change to 1.9/1.10/1.11 respectively for versions)

export JAVA_HOME=$(/usr/libexec/java_home -v1.8)

Run the .bash_profile script by the following command

source .bash_profile

To validate

echo $JAVA_HOME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment