If you have more than one Java JDK version installed in your system, you may be able to switch back and forth depending on the project or the compilation environment, and there are two very handy ways to choose between them.
I have Java 7 and Java 8 on my machine, and you are modifying it according to your own JDK version.
Method One: in your home directory. Add the following to the Bash_profile file, or create one yourself if the file does not exist.
Export JAVA_HOME_7=/LIBRARY/JAVA/JAVAVIRTUALMACHINES/JDK1. 7. 0_71.jdk/contents/homeexport java_home_8=/library/java/javavirtualmachines/jdk1. 8. 0_51.jdk/contents/homeexport java_home=$JAVA _home_7alias jdk8='Export Java_home= $JAVA _home_8'alias jdk7='export java_home= $JAVA _home_7 '
Method Two:
1.8 ) Export Java_7_home1.7) export Java_home=$JAVA _7_homealias jdk8=" Export java_home= $JAVA _8_home"alias Jdk7="export java_home= $JAVA _7_home "
The second method of personal recommendation. The reason is obvious.
Switch tips for multiple JDK versions under Mac OS X