MAC OSX installs multiple versions of Java

Source: Internet
Author: User

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

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.