After JDK8 GA, the small partners like to rush, have been eager to experience a Java8 lambda and other new features, but the current Java enterprise application of the main version is JDK6, JDK7. Therefore, I need to have jdk8,jdk7,jdk6 on my computer at the same time. JDK6 and JDK7 mainly do some product code verification, as well as play some of their own open-source projects, JDK8 is purely early adopters, who called us a hate programmer.
target at the command line, you can easily switch to the corresponding Java version by command ' Jdk6 ', ' jdk7 ', ' jdk8 '. The default initial setting is Jdk7.  
procedure  
1. First Install all jdk:
* Mac comes with the JDK6, installed in the directory:/system/library/java/javavirtualmachines/1.6.0.jdk/. * Jdk7,jdk8 will need to download and install the corresponding version on the Oracle website. The default path for your own JDK installation is:/LIBRARY/JAVA/JAVAVIRTUALMACHINES/JDK1.8.0.JDK 
2. The path to configure Java_home in the Bash configuration file in the user directory: BASHRC
Export java_6_home=/system/library/java/javavirtualmachines/1.6. 0.jdk/contents/home
Export JAVA_7_HOME=/LIBRARY/JAVA/JAVAVIRTUALMACHINES/JDK1. 7.0.jdk/contents/home
Export JAVA_8_HOME=/LIBRARY/JAVA/JAVAVIRTUALMACHINES/JDK1. 8.0.jdk/contents/home
Export Java_home= $JAVA _7_home
Export Java_6_home=/system/library/java/javavirtualmachines/1.6.0.jdk/contents/homeexport JAVA_7_HOME=/Library/ Java/javavirtualmachines/jdk1.7.0.jdk/contents/homeexport java_8_home=/library/java/javavirtualmachines/ Jdk1.8.0.jdk/contents/homeexport java_home= $JAVA _7_home
3. Create the alias command to dynamically switch Java_home configuration
-
Alias jdk8= ' export java_home= $JAVA _8_home '
-
Alias jdk7= ' export java_home= $JAVA _7_home '
-
Alias jdk6= ' export java_home= $JAVA _6_home '
Alias jdk8= ' export java_home= $JAVA _8_home ' Alias jdk7= ' export java_home= $JAVA _7_home ' Alias jdk6= ' export java_home=$ Java_6_home '
Authentication
Cnxnliu:versions xnliu$ java-version
Java version "1.6.0_65"
Java (TM) SE Runtime Environment (build 1.6.0_65-b14-462-11m4609)
Java HotSpot (TM) 64-bit Server VM (build 20.65-b04-462, Mixed mode)
Cnxnliu:versions xnliu$ Jdk8
Cnxnliu:versions xnliu$ java-version
Java version "1.8.0"
Java (TM) SE Runtime Environment (build 1.8. 0-b132)
Java HotSpot (TM) 64-bit Server VM (Build 25.0-b70, Mixed mode)
Cnxnliu:versions xnliu$
650) this.width=650, "src=" http://images.cnitblog.com/blog/437282/201411/041405283617635.gif "width="/>
Install multiple versions of the JDK at the same time under Mac