Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I print out the path in bash, it prints this:


When I run System.out.println(System.getenv("PATH")); in Java running under Eclipse, it prints


How can I figure out why there is this discrepancy? I need to add /usr/local/bin to the PATH and make it available to Java apps under Eclipse. (note: I have made no modifications system paths, so these are the defaults set by the OS or perhaps by one or more of the applications i've installed.)

share|improve this question

If you want to set an variable system wide on OSX you need to put it in your ~/.MacOSX/environment.plist file.

See this page on the apple website for more detail.

share|improve this answer
I think this is the right answer, anyway it worked for me. – spacemanaki Dec 3 '10 at 22:44
Unfortunately, this doesn't seem to work for me. – thSoft Nov 19 '12 at 22:44

Had the same problem. Here is my solution:

  1. Edit the /etc/paths file to include the desired additional path.

  2. For a OSX installation, run /Applications/eclipse/eclipse not /Applications/eclipse/

share|improve this answer
omg number 2 on here was the solution to SO MUCH FRUSTRATION. Thanks!! – Tommy Oct 2 '13 at 16:39
I registered to this website just so I could upvote this answer - item #2 fixed it! – Iftah Jul 6 at 8:28
up vote 3 down vote accepted

Aha, I found this webpage which says

Note: Mac OS X does not include /usr/local/bin in its default PATH. Therefore, assuming you're using the default bash shell, please type (or include in /etc/profile) export PATH=/usr/local/bin:$PATH before using any of these tools.

Is this an appropriate/inappropriate thing to do? I get leery of editing system files unless I really know what I'm doing. /usr/local/bin is only writeable by root so I wouldn't be opening a security hole, would I?

Odd, I added the export path, and it has no effect on eclipse run from the Dock. Also I found this page about paths and my /etc/paths file has


and yet those paths don't show up in eclipse... is there an easy way to create/find a binary file that prints out $PATH, that I could run from the Dock, so I could debug this more easily? I don't know if Eclipse mucks around with the path.

share|improve this answer
+1 for your final question. I'm wondering how to diagnose path issues in OS X not in bash or the Terminal. – fideli Jan 21 '10 at 0:19

Most likely, one of your bash login scripts (.bashrc or .bash_profile) is changing $PATH. If you start Eclipse from the terminal, does it get /usr/local/bin in its path?

share|improve this answer
good call! If I run Eclipse from the terminal, it has /usr/local/bin in the path. Now what should I do? Isn't /usr/local/bin something that should be in the path to all applications? which script can I put this in, so that if I run Eclipse from Finder or from the Dock, it will be in the path? – Jason S Aug 23 '09 at 19:32
Also I don't have a .bashrc or .bash_profile in my user directory. – Jason S Aug 23 '09 at 19:33

This tip above works for me: 1) add path to /etc/paths as root 2) start eclipse with $ECL_HOME/ instead of $ECL_HOME/

share|improve this answer

Alternatively you might just add a symbolic link to your /usr/local directory pointing to your application.

E.g. do as root:

ln -s /Applications/PhantomJS/phantomjs-1.9.2-macosx/bin/phantomjs /usr/local/phantomjs

This helped me to run (mvn test) the external PhantomJS application from within a Maven project in Eclipse.

share|improve this answer
This does not seem to have anything to do with $PATH or directories in $PATH like /usr/local/bin. Could you please explain in more details? – pabouk Oct 18 '13 at 10:00
you put a symbolic link somewhere in the path, that points to the actual location which is not in the path. I've done it before, it works for single executables, doesn't work for a directory full of files – Jason S Oct 18 '13 at 19:37

If you are on Eclipse (tested with "Mars"), you could change your "Run Configuration":

  1. Click on "Run" → "Run Configurations..."
  2. Choose the appropriate run configuration on the left
  3. Now choose tab "Environment"
  4. Click on "New..."
  5. In the "Name" field, enter "PATH"
  6. Now go to your Terminal, enter "echo $PATH" and copy the result
  7. Past the result into the "Value" field
  8. Klick "OK"
  9. Back in the "Environment" tab, make sure you select "Append environment to native environment"

Now Eclipse uses the same values for the PATH environment variable as your system does. Remember: This is only true for the run configuration you chose.

As already noted in your question, check in Java with:

share|improve this answer

You can modify the global osx path by adding a line to /etc/launchd.conf and rebooting your computer.

setenv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Works in OSX 10.8 and 10.9

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .