The first time with the development of the Mac, on the Internet also search some environment variable configuration articles, summarized in this to facilitate future use.
1, open terminal terminal;
2, enter the current user home directory, CD ~;
3, temporary authorization, sudo su;
4, enter the password (password does not display);
5. Create a. bash_profile file, touch. Bash_profile (if there is no new, I do not);
6. Open the. bash_profile file, opening bash_profile (can open then new success);
7, the input JDK file path, the system default is 1.6, my is 1.8, can be configured for two, convenient later switch.
Export Java_6_home=/library/java/javavirtualmachines/1.6.0.jdk/contents/home
Export Java_8_home=/library/java/javavirtualmachines/jdk1.8.0_51.jdk/contents/home
Export Java_home= $JAVA _8_home
Save and exit;
8. Read and execute the commands in the file, source. bash_profile;
9. Enter Java-version in terminal to display JDK information, then the configuration is successful.
Transfer from https://www.cnblogs.com/zhouhongfu1991/p/5967807.html
Configuring JDK Environment variables under MAC system