JAVA environment variable configuration steps in mac

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
insert image description here

02 Click Download Java
insert image description here
03 Scroll down to select java8 --> macOS (Windows system select Windows) --> Download
insert image description here
04 Click to download (login oracle will be displayed, you can search account password or register one, download directly after login)
insert image description here

Second, the installation of JDK

After the download is complete, we get a dmg installation package, as shown in the figure:

insert image description here
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

insert image description here

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

insert image description here
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

Guess you like

Origin blog.csdn.net/weixin_44127674/article/details/130535640