How to edit PATH variable on Mac
Posted by Alberto - 23/05/09 at 10:05:19 pmIf you need to change your PATH variables (or another environment variable, as CLASSPATH) on a Mac OS X, you need to edit a file called .profile located in your home directory. Open a terminal window and type:
open -e ~/.profile
In case you dont have a .profile file, you have to create it:
touch ~/.profile
You have to include a line like this:
export PATH=(path-you-want-to-add):$PATH
For example, lets imagine you want to add the file whatever.jar, located in your Documents folder. You would write:
export PATH=~/Documents/whatever.jar:$PATH
Easy, isnt it?
May 23, 2009 | In Mac OS X | 2 Comments
2 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds.
Valid XHTML and CSS.



Thanks a lot! You saved me a lot of time and trouble. In a few lines, you explained what other sites using entire pages had failed to explain.
Comment by Ali — August 8, 2009 #
This is really nice but i need a bit more help.
Whenever i type ‘echo $PATH’
only ever got back my old PATH – which i found impossible to change
Until now!
I created a .Profile file in my root directory (Mac:)
I copied my text edited file **
Now my echo $PATH reads perfect when I ask Terminal
My questions are:
1.If you don’t have a .profile file in the correct place – what are the possible locations that terminal reads and writes to when you type in ‘echo $PATH’ and sudo vi .bash_login (to edit this path)
OR what file is it reading to show you your $PATH!!! (because i was not able to change a file which reflected a change in $PATH in terminal
2.What is the root directory? is it MAC: or MAC/users/myname/
Now i have .profile files everywhere!!!
I just have big problems understanding what Terminal is editing and showing when you edit the $PATH via the sudo vi .bash_login OR sudo vi .bash_profile (my files were never showing a universally similar PATH)
Comment by Chris — May 14, 2010 #