Center os 用户环境变量修改
open ~/.bash_profile进入用户环境变量设置
export JAVA_HOME=/usr/java/jdk1.7.0_76
export JAVA_BIN=$JAVA_HOME/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
source ~/.bash_profile --使配置文件起作用
printenv --查看环境变量
MaC环境变量设置
Mac系统的环境变量,加载顺序为:
- /etc/profile
- /etc/paths
- ~/.bash_profile
- ~/.bash_login
- ~/.profile
- ~/.bashrc
当然/etc/profile
和/etc/paths
是系统级别的,系统启动就会加载,后面几个是当前用户级的环境变量。后面3个按照从前往后的顺序读取,如果~/.bash_profile
文件存在,则后面的几个文件就会被忽略不读了,如果~/.bash_profile
文件不存在,才会以此类推读取后面的文件。~/.bashrc
没有上述规则,它是bash shell打开的时候载入的。
设置PATH的语法都为:
export PATH=$PATH:<PATH 1>:<PATH 2>:<PATH 3>:------:<PATH N>
两个方式设置环境变量
修改当前用户的环境变量
推荐方式是修改~/.bash_profile
export ANDROID_HOME=/Users/chenli4/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:/Users/chenli4/Library/Android/sdk/platform-tools
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
修改系统的环境变量
Mac系统的环境变量,加载顺序为:
- /etc/profile
- /etc/paths
- ~/.bash_profile
- ~/.bash_login
- ~/.profile
- ~/.bashrc
当然/etc/profile
和/etc/paths
是系统级别的,系统启动就会加载,后面几个是当前用户级的环境变量。后面3个按照从前往后的顺序读取,如果~/.bash_profile
文件存在,则后面的几个文件就会被忽略不读了,如果~/.bash_profile
文件不存在,才会以此类推读取后面的文件。~/.bashrc
没有上述规则,它是bash shell打开的时候载入的。
设置PATH的语法都为:
export PATH=$PATH:<PATH 1>:<PATH 2>:<PATH 3>:------:<PATH N>
两个方式设置环境变量
修改当前用户的环境变量
推荐方式是修改~/.bash_profile
export ANDROID_HOME=/Users/chenli4/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:/Users/chenli4/Library/Android/sdk/platform-tools
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
修改系统的环境变量
推荐方式是修改/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/jdk-10.0.2.jdk/Contents/Home"
export JAVA_HOME
CLASS_PATH="$JAVA_HOME/lib"
export ANDROID_HOME=/Users/chenli4/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=$JAVA_HOME/bin:$PATH
比如把jdk10变成jdk8
打开Sublime Text,修改/etc/profile
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home"
保存(需要输入密码)