1、下载安装jdk
地址:https://www.oracle.com/technetwork/java/javase/downloads/index.html
2、配置环境变量
sudo vi /etc/profile
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home"
export JAVA_HOME
CLASS_PATH="$JAVA_HOME/lib"
PATH=".$PATH:$JAVA_HOME/bin"
3、验证
java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
echo $JAVA_HOME :查看java的环境变量
echo $PATH:查看环境变量地址