Table of contents
1. Download, install and configure JDK
Download jdk from the official website
1. Enter the download address: https://www.oracle.com/downloads/
01 Click Products
, slide down to see java
02 Click Download Java
03 Scroll down to select java8 --> macOS (Windows system select Windows) --> Download
04 Click to download (login oracle will be displayed, you can search account password or register one, download directly after login)
Second, the installation of JDK
After the download is complete, we get a dmg installation package, as shown in the figure:
Double-click the downloaded installation package file
and the installation is complete, the path is your default
3. JDK environment configuration
Open a terminal window and execute the following command
/usr/libexec/java_home -V
Fourth, configure environment variables
4.1 Create and open the configuration file .bash_profile (if you already have this file, just edit it directly)
1. I already have a .bash_profile file here
vim .bash_profile
In order to demonstrate better, I first delete
2, delete command
rm -f ~/.bash_profile
3. Create and open the configuration file .bash_profile
touch .bash_profile 新建
open -e .bash_profile 打开
4. Copy the configuration information into
JAVA_HOME=我的jdk路径
PATH=$JAVA_HOME/bin:$PATH:.
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export JAVA_HOME
export PATH
export CLASSPATH
After copying in, ctrl+s saves
5. Effective configuration file
source ~/.bash_profile