As of June 30, 2021, the official Oracle JDK version has been updated to Java SE 16.0.1, but the majority of enterprises use JDK8. This article uses JDK8 as an example.

1.JDK8 for MAC OS

www.oracle.com/hk/java/tec…

1.1 Scroll down to find the version

1.2 Click the left button to download the file and continue all the way. You need to enter your computer password during the process.

1.3 After the installation is completed, click the close button as shown in the figure

1.4 Remove the downloaded files to the wastebasket

2 Configure environment variables

2.1 Open the MAC Terminal and enter the following code to query the JDK installation path.

/usr/libexec/java_home -V
Copy the code

The red box in PS is the installation path of the JDK, copy it, later use *

2.2 If built before.bash_profileHide the configuration file and enter it directly on the terminalopen -e .bash_profileOpen the file. If not, enter the following command.

vim .bash_profile
Copy the code

2.3 After entering viM, press I on the keyboard to enter editing mode; Put the following parameters into it and save (press Esc to enter :wq! Command + S) to exit the editing mode. Note that JAVA_HOME is the JDK installation path mentioned in 2.1 above. Put your JDK installation path here and here, and save it

JAVA_HOME = / Library/Java/JavaVirtualMachines jdk1.8.0 _291. JDK/Contents/Home PATH = $JAVA_HOME/bin: $PATH:. CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:. export JAVA_HOME export PATH export CLASSPATHCopy the code

2.4 Run the following command to make the configuration file take effect

$ source .bash_profile

Copy the code

2.5 Run the following command to check the path of environment variables and check whether the configuration is successful

echo $JAVA_HOME
Copy the code

2.6 Run the following command to view the JDK version information

$ java -version
Copy the code

Summary: So far, the Mac platform JDK installation and environment configuration has been completed, relatively simple so do not make special description. Email me if you have any questions:[email protected]