Mac's own jdk1.6 is a modified version of Apple's own, is widely used in a variety of Mac software, it is irreplaceable, at the same time, Oracel released jdk1.7 and jdk1.8 sometimes need to use. Therefore, it is important to install and use multiple versions of the JDK on your Mac. The following are examples of how to install and use jdk1.6 and jdk1.8.
1. Download the jdk1.8 installation package from the Java website and click Install. After this step, the command line input java-version is still displayed as 1.6 because the jdk1.8 is installed, but is not configured.
2. Now start the configuration: the jdk1.8 home folder is soft connected to the Usr/libexec folder, the reason for the soft connection is because the jdk1.8 default installation directory is/Library/Internet plug-ins/ Javaappletplugin.plugin/contents/home, which have spaces, will cause an error when the next alias command is made, but not after the soft connection. The code is as follows:
sudo Ln -s/library/internet plug-ins/javaappletplugin.plugin/contents/home/usr/libexec/java_8_home
3. Open ~/.bash_profile, no words created
Vim ~/.bash_profile
4. Write in file, save, exit
Export java_6_home=$ (/usr/libexec/java_home) #这是mac自带的jdk1.6 HOME directory Java_8_home="/usr/ Libexec/java_8_home"#这是我们软连接的jdk1.8 directory export java_8_home java_home=$JAVA _6_home # The default choice is Jdk1.6alias jdk6="export java_home= $JAVA _6_home" #编辑一个命令jdk6, the input goes to jdk1.6 alias Jdk8="export java_home= $JAVA _8_home" #编辑一个命令jdk8, the input goes to jdk1.8
5. Restart. If you want to use jdk1.6 in the future, enter JDK6 at the command line and enter JDK8 if you want to use jdk1.8. Simple burst.
MAC OSX installs multiple versions of Java