First open the terminal, enter/usr/libexec/java_home, see
/library/java/javavirtualmachines/jdk1.7.0_51.jdk/contents/home
Note that Java is already installed, now let's configure java_home, because this environment variable is used in many Java-related open source projects, and if it is used temporarily, enter it directly:
Export java_home=$ (/usr/libexec/java_home)
When this terminal is closed it will expire, and to set it to be permanent, we usually do this:
Create and open the ~/.bash_profile file in a TextEdit manner
Touch ~/.bash_profile;open-t ~/.bash_profile
java_home=$ (/usr/libexec/java_home-v 1.7)
Export Java_home
Finally, don't forget if. Bash_profile is just created and needs this sentence to make the configuration effective:
source. bash_profile
Finally cmd+t new window, enter
Echo $JAVA _home
To see if the configuration is global in effect
Mac Configuration Java_home