mac 配置java环境

下载jdk

https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html

下载后安装jdk

查看是否安装成功

命令行输入:java -version

配置PATH和CALSSPATH路径

打开这个路径下的文件 /etc/profile   (etc是mac的隐藏目录默认是隐藏的,打开隐藏目录  shift+cmmand+. )

查看安装的JDK版本

打开Finder找到        /Library/Java/JavaVirtualMachines/

在文件末尾添加JAVA_HOME路径

JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk(这里是你电脑中安装的jdk版本文件夹)/Contents/Home/"

CLASS_PATH="$JAVA_HOME/lib"

PATH=".:$PATH:$JAVA_HOME/bin

 实例:

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
	eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
	[ -r /etc/bashrc ] && . /etc/bashrc
fi

JAVA_HOME="/Library/Java/JavaVirtualMachines/⁨jdk1.8.0_181.jdk⁩/Contents/Home/"

CLASS_PATH="$JAVA_HOME/lib"

PATH=".:$PATH:$JAVA_HOME/bin"

生效的命令

lianhezhongshengdeMacBook-Pro:~ panchenchen$ source /etc/profile

查看JAVA_HOME是否配置成功

在命令行输入    echo $JAVA_HOME

lianhezhongshengdeMacBook-Pro:~ panchenchen$ echo $JAVA_HOME

返回这串就是成功了⤵️

/Library/Java/JavaVirtualMachines/⁨jdk1.8.0_181.jdk⁩/Contents/Home/

 

你可能感兴趣的:(工具)