Mac OSX - 如何在bash_profile中配置全局环境变量

我们知道,在Linux操作系统下,配置环境变量是使用如下命令:

vim /etc/profile

在OSX下,我们用如下命令打开环境变量配置文件:

open ~/.bash_profile

 

典型的环境变量配置如下:

 

# java
export JAVA_HOME = /home/myuser/jdk1.7.0_03
export PATH = $JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

# hadoop
export HADOOP_HOME=/Users/YourUserName/Documents/Dev/hadoop-2.7.3
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

# spunk
export SPLUNK_HOME=/Applications/Splunk
export PATH=$PATH:$SPLUNK_HOME/bin

# Setting PATH for Python 3.5
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH

export CLASSPATH=${CLASSPATH}:/Users/YourUserName/Documents/Lib/hadoop_cli

# ant
export ANT_HOME=/Users/YourUserName/Documents/Dev/apache-ant-1.9.7
export PATH=$PATH:${ANT_HOME}/bin

# JBOSS
export JBOSS_HOME=/Users/YourUserName/Documents/Dev/wildfly-10.1.0.Final
export PATH=$PATH:$JBOSS_HOME/bin

# M2_HOME
export M2_HOME=/Users/YourUserName/Documents/Dev/apache-maven-3.3.9
export PATH=$PATH:$M2_HOME/bin

最后,别忘了编译下

source .bash_profile

 

上一篇:GitHub或者CSDN写博客的简单语法


下一篇:亚马逊route 53服务介绍