Mac system different Java version switch

Source: Internet
Author: User

#确认jdk版本

/usr/libexec/java_home

#会得到下面信息 (different versions are displayed differently)

/library/java/javavirtualmachines/jdk1.7.0_60.jdk/contents/home

#上面是1. Version 7 JDK, you can use the-V ID to get other installed versions of the JDK, such as: The 1.6 version of the JDK that comes with the system

/usr/libexec/java_home-v ' 1.6* '

#会得到下面信息 (Mac OS X 10.9.4 comes with 1.6JDK)

/system/library/java/javavirtualmachines/1.6.0.jdk/contents/home

Get the above information and start creating a configuration file

#创建. Bash_profile configuration file (Skip this step if you already have the file)

Touch ~/.bash_profile

#vim编辑. bash_profile file

Vim ~/.bash_profile

#如果不习惯vim命令就使用自带的文本编辑器打开

Open ~/.bash_profile

#将下面内容输入到. Bash_profile Inside

# mac default JDK 6 (Mac default comes with a jdk6 version) export java_6_home=$ (/usr/libexec/java_home-v 1.6) # set JDK 7export java_7_home=$ (/usr/ Libexec/java_home-v 1.7) #默认JDK 7export java_home= $JAVA _7_home#alias command dynamically switch JDK version alias jdk6= "Export java_home= $JAVA _6_ HOME "Alias jdk7=" Export java_home= $JAVA _7_home "

#输入完成后保存执行下面命令

#重新执行. bash_profile file

SOURCE ~/.bash_profile

#切换直接终端输入jdk6或jdk7来切换jdk版本

Get JDK version, edit. Bash_profile

. bash_profile Configuration file Contents

All commands, JDK version switch from: http://blog.sina.com.cn/s/blog_63fea2670102uwpt.html

Mac system different Java version switch

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.