I used to use the direct command. Brew Cask install Java, install the following version of Java:
? ~ $ Ls-lh ' which Java ' lrwxr-xr-x 1 root wheel 74B 19:07/usr/bin/java Works/javavm.framework/versions/current/commands/java? ~ $ Java-versionjava Version "1.8.0_51" Java (tm) SE Runtime Environment (build 1.8.0_51-b16) Java HotSpot (TM) 64-bit SE RVer VM (build 25.51-b03, Mixed mode)
I wanted to install JDK1.7, so I downloaded jdk-7u80-macosx-x64.dmg from Oracle.
Next do not want to write, reproduced from http://www.bjhee.com/mac-jdk.html, but according to the situation of cyper made adjustments:
=================
The installation of Oracle JDK in Mac system is simple, but some of them are different from Linux, so make a record. This example uses JDK 1.7, also Java SE 7, as an example. However, different versions are basically the same way of installation.
- Download JDK
Download the JDK from the official website "http://www.oracle.com/technetwork/java/javase/downloads/index.html". Remember that it is the JDK, do not download the JRE, this will lack a lot of developed libraries. Select the Mac OS x package, in this case the "jdk-7u80-macosx-x64.dmg" file is downloaded.
- Installing the JDK
DMG Package installation is quite simple, just double-click the DMG file, follow the prompts to continue. After installation, you can find the Java settings in System Preferences. Here, we don't need to modify any settings.
- Configuring Environment variables
We are going to add the Java command to the system environment variable "PATH". On Mac, Java is installed by default in the "/library/java/javavirtualmachines/jdk1.7.0_80.jdk/contents/home/" directory. Note that the middle "jdk1.7.0_80.jdk" directory will change depending on the version.
Open the ". Bash_profile" file in the user directory
$ VI ~/.bash_profile
Add the following configuration
0 S |
Export Java_home =/library/java/javavirtualmachines/jdk1.7.0_80.jdk/contents/home ExportPATH=$Java_home/bin:$PATH |
Enter the following command to make the configuration take effect immediately
$ source ~/.bash_profile
After seeing the information below, it proves that the JDK has been installed successfully.
? ~ $ Java-versionjava Version "1.7.0_80" Java (tm) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot (TM) 64-bit SE RVer VM (build 24.80-b11, mixed mode)? ~ $
Installation configuration for Oracle JDK under Mac