11. Open terminal window
22. Type command: $ vim ~/.bash_profile and Hit Enter
33. Type command: $ export JAVA_HOME=$(/usr/libexec/java_home) and press Escape key for Save changes.
44. Type command: :(colon)wq, It will Save and close .bash_profile file.
55. Type command: source ~/.bash_profile and hit Enter
66. Now we can check the value of the JAVA_HOME variable:
77. Type Command: echo $JAVA_HOME
8 The result should be the path to the JDK installation:
9 /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home