"Original" Mac OS X installs multiple versions of JDK simultaneously (JDK 1.5 ~ JDK 1.8)

Source: Internet
Author: User
Tags oracle java download

While the official version of Java 8 has been released for more than two years, the current flagship version of Java Enterprise Applications is Java 6 and Java 7, and even worse, some of the company's early projects have to be run under Java 5, and I want to experience the new features of Java 8 in addition to working. So I need to install JDK 1.5,JDK 1.6, JDK 1.7 and JDK 1.8 on my Mac at the same time.

In the past, Java on MAC was provided by Apple itself, but only to Java 6, and the system was no longer installed by default from OS X 10.7 (optional installation, originally with JDK 1.6). Later, Apple joined the OpenJDK camp to continue supporting Java 6, and Oracle was responsible for providing it starting with Java 7. Think of it as Apple pie and Oracle pie for the moment.

Enter java-version in Terminal to view the current JDK version information, if you do not have any JDK installed, you will be prompted to install, click to jump to the oralce Java download page.

System environment

OS X EI Capitan (version 10.11.5)

Pre-preparation
    1. Java installation package
      • JDK 1.5: Java for Mac OS X 10.5 Update (from:apple)
      • JDK 1.6: Java for OS X 2015-001 (from:apple)
      • JDK 1.7 and above : Java Chinese official website or Oracle java Download (from:oracle)
    2. Auxiliary tools
      • pacifist: Used to extract files from the *.DMG installation package (click I download)
Installation steps

The installation process for JDK 1.6 and above is simple and does not repeat. The following highlights the process of installing JDK 1.5.

  1. To delete the default catalog file from the system:

    sudo RM /system/library/frameworks/javavm.framework/versions/1.5. 0

  2. Use pacifist to extract the files in Java for Mac OS X 10.5 Update 10:

    • On JAVAFORMACOSX10.5UPDATE10.DMG, right-click Open mode, pacifist
    • Locate the/system/library/frameworks/javavm.framework/versions/directory, select 1.5 and 1.5.2 directories, right-click Install to default location
  3. TerminalIn the installation directory of JDK 1.5, verify that the installation is successful:
     1  $ cd/system/library/frameworks/javavm.framework/versions/1.5 . 0 /home/bin  2  $./java-3  java version  1.5.0_30   " 4  Java (TM) 2  Runtime Environment, Standard Edition (build 1.5 . 0_30-b03- 389 -11m4833)  5  Java HotSpot (TM) Server VM (build 161 , Mixed mode) 

     

Installation path

The Apple-sent JDK 1.6 is different from the installation path of JDK 1.5 on OS X, and JDK 1.6 is consistent with the installation path of the Oracle-sent JDK, which requires special attention.

Installation path for JDK 1.5:/system/library/frameworks/javavm.framework/versions/1.5.0
Installation path for JDK 1.6:/LIBRARY/JAVA/JAVAVIRTUALMACHINES/1.6.0.JDK

The default JDK version of the system is implemented via link , which means that Java programs, such as Maven and Eclispe, choose which JDK to search for Java programs by their own startup scripts, according to the agreed link file. Maven, for example, would look for an Apple-sent JDK and find the Oracle-sent JDK.

Apple-Sent JDK /system/library/frameworks/javavm.framework/versions/currentjdklink to a version of the JDK Multi-version support was implemented.

The Oracle-Sent JDK learning Aplle method also supports multiple versions, and thelink file is /system/library/frameworks/javavm.framework/versions/current .

In EclipseConfiguring the JRE in

Preferences, Java, installed JREs, adds the installed versions of the JDK to the list.

Note: This article does not contain sections of the JDK multi-version management switch.

Reference
    1. Mac OSX 10.9 Installation jdk1.5
    2. Install multiple versions of JDK and switch several ways under Mac
    3. How to use multiple JDK versions in OSX

"Original" Mac OS X installs multiple versions of JDK simultaneously (JDK 1.5 ~ JDK 1.8)

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.