How to use multiple JDK versions in OS X

Source: Internet
Author: User

How to use multiple JDK versions in OS X
After upgrading the hard disk of the macbook to an SSD, the system and JDK 8 are re-installed. However, to start eclipse, we still reported that JDK 6 needs to be installed. Therefore, we installed Apple JDK 6 as prompted, this results in two JDK versions in the system: Oracle JDK 8 and Apple JDK 6. Run java-version on the command line and the prompt is JDK 8. It seems that everything is normal, but run the mvm clean install command to find that maven uses JDK 6! Confused. What's going on? -------- Gorgeous split line --------

The original OSX Java installation path is divided into two schools: one is the Apple School and the other is the Oracle School.


Oracle sends JDK installation to the/Library/Java/JavaVirtualMachines/jdk1.8.0 _ 05.jdk/ Contents directory; Apple sends JDK installation to the/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents directory; the default JDK version of the system is implemented through link. That is to say, java programs, such as maven and eclispe, use their own startup scripts to select the appropriate JDK, find the java program according to the agreed link file. For example, maven will first find the Apple JDK and then the Orale JDK. How does Apple's JDK support multiple versions? Just link the file/System/Library/Frameworks/JavaVM. framework/Versions/CurrentJDK to a specific version of JDK. Oracle's JDK also supports multiple versions. How does it implement it? In the same way as Apple, link to JDK installation paths of different Versions. The link file of Oracle is/System/Library/Frameworks/JavaVM. framework/Versions/Current. How can we solve the problem of using Apple's JDK 6 in maven instead of the latest Oralce JDK 8? Let's take a look at the maven STARTUP script. Many original java frameworks will give developers a chance to prioritize the JDK directory you are using. For example, maven will first check whether JAVA_HOME has been set, if you have set the jdk path, use the default JDK path of Apple. Otherwise, find the default JDK of Oracle. The solution is to set the JAVA_HOME environment variable to the installation directory of Oracle JDK 8. The specific command is as follows: Edit ~ /. Bash_profile, add the following line: export JAVA_HOME =/Library/Java/JavaVirtualMachines/jdk1.8.0 _ 05.jdk/ Contents/Home Appendix: to modify the JDK used when eclipse is started, you can do this: edit eclipse_kepler/Eclipse. eclipse in app/Contents/MacOS. ini, add the following two lines-vm/Library/Java/JavaVirtualMachines/jdk1.7.0 _ 55.jdk/ Contents/Home/bin/java

Install JDK 1.8.0 _ 25 on Ubuntu 14.04 and configure Environment Variables

Build a JDK environment using CentOS

Install JDK 1.8.0 _ 25 on Ubuntu 14.04 and configure Environment Variables

Install Oracle JDK 14.04 on Ubuntu 1.8 LTS

CentOS6.3 install JDK and environment Configuration

Install JDK 8 on Ubuntu 14.04

Install JDK graph analysis in Ubuntu

This article permanently updates the link address:

Related Article

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.