Install multiple versions of the JDK at the same time under Mac

Source: Internet
Author: User

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

  1. Export java_6_home=/system/library/java/javavirtualmachines/1.6. 0.jdk/contents/home

  2. Export JAVA_7_HOME=/LIBRARY/JAVA/JAVAVIRTUALMACHINES/JDK1. 7.0.jdk/contents/home

  3. Export JAVA_8_HOME=/LIBRARY/JAVA/JAVAVIRTUALMACHINES/JDK1. 8.0.jdk/contents/home

  4. 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

    1. Alias jdk8= ' export java_home= $JAVA _8_home '   

    2. Alias jdk7= ' export java_home= $JAVA _7_home '   

    3. 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

  1. Cnxnliu:versions xnliu$ java-version

  2. Java version "1.6.0_65"

  3. Java (TM) SE Runtime Environment (build 1.6.0_65-b14-462-11m4609)

  4. Java HotSpot (TM) 64-bit Server VM (build 20.65-b04-462, Mixed mode)

  5. Cnxnliu:versions xnliu$ Jdk8

  6. Cnxnliu:versions xnliu$ java-version

  7. Java version "1.8.0"

  8. Java (TM) SE Runtime Environment (build 1.8. 0-b132)

  9. Java HotSpot (TM) 64-bit Server VM (Build 25.0-b70, Mixed mode)

  10. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.