Thursday, September 25, 2008

Setting Environment Variables on Mac

It is essential to set up a list of environment variables that are specific to a specific development environment. Below are the step on how to accomplish this on MacOS:

1. Open a text file and save it as .bash_profile:
# User specific Terminal config
if [ -n "$PS1" ]; then PS1='\u@\h:\w \$ '; fi
shopt -s checkwinsize

echo ~/.bash_profile

export PATH=$PATH:/usr/local/bin

####### JAVA DEV #######
export JAVA_HOME=/Library/Java/Home/
export PATH=$PATH:$JAVA_HOME/bin


2. Save .bash_profile under main user directory in the HD.
3. Restart your terminal window.
4. Verify in the terminal that you have the correct path for the env var. you just set up:
echo $JAVA_HOME