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 ', and the default initial setting is Jdk7.
Practices
1. Install all the JDK first:
* Mac comes with JDK6, installed in 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. Configure the path to 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/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 '
Authentication
Cnxnliu:versions xnliu$ Java-Versionjavaversion "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$ jdk8cnxnliu:versions xnliu$ java-versionjava 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 Span class= "Hljs-keyword" >mode) cnxnliu:versions xnliu$
Install multiple J-D K
under your Mac