Mac 配置Java环境变量

Mac Java配置环境

下载Java包

地址:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
下载mac版:Java SE Development Kit 8u261
java下载项

进行环境变量设置

下载后查看java版本:java -version

// 下载后查看java版本
sgy@localhost ~ % java -version        
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

进行环境变量配置:sudo vim /etc/profile

sgy@localhost ~ % sudo vim /etc/profile
# 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_77.jdk/Contents/Home/"
CLASS_PATH="$JAVA_HOME/lib"
PATH=".:$PATH:$JAVA_HOME/bin"                                   

因为为是sudu打开所以需要强制保存:wq!

重启terminal或者用如下命令使生效

sgy@localhost ~ % source /etc/profile

查看配置后的环境变量

sgy@localhost ~ % echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/
相关推荐
©️2020 CSDN 皮肤主题: 1024 设计师:白松林 返回首页