Download and install
oracle official website to download, address: https: //www.oracle.com/technetwork/java/javase/downloads/index.html
Once you have downloaded, click on the installation package, click the back has been performed can be installed
Environment Configuration
1, View jdk installation path
Terminal Open -> input commands: / usr / libexec / java_home -V
(1) Start station search "Terminal", open a terminal
(2) input command "/ usr / libexec / java_home -V", record lookup path
Acquired jdk path: /Library/Java/JavaVirtualMachines/jdk-13.jdk/Contents/Home (only an example, to record their little friends need to get to the jdk path)
2, configure the environment variables
Jdk environment variable as follows:
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.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 CLASSPATH
(1) for the first time configuration environment variable
Initial configuration must first create a new profile, the terminal input "touch .bash_profile" to the new hidden .bash_profile configuration files
Open the configuration file, the input terminal "open -e .bash_profile" open
.bash_profile file, enter the environment variables content
.bash_profile file, enter the jdk environment variable can save close
(2) non-first-time configuration environment variables (you can directly edit)
Terminal input "open -e .bash_profile" open the configuration file, write jdk environment variable content can be stored close
(3)使配置文件生效,终端输入指令“source .bash_profile”
(4)验证环境配置成功,终端输入指令“echo $JAVA_HOME”
显示jdk路径即配置已生效