PATH env variable on Mac OS X and/or Eclipse
When I print out the path in bash, it prints this:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
When I run System.out.println(System.getenv("PATH")); in Java running under Eclipse, it prints
/usr/bin:/bin:/usr/sbin:/sbin
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.)
For those of you looking for an answer years later (Neon, Oxygen):
Some of my node and angular/angular2 tooling in eclipse failed due to missing $PATH entries in the MacOS terminal. Your tooling propably utilizes the embedded eclipse terminal which does not start providing your login/user shell. So you need to set the eclipse terminal in your eclipse preferences to start as --login shell in order to comprise your users PATH settings:
Go to:
Preferences -> Terminal -> Local Terminal
and set
Arguments
to: --login
open a new Terminal inside Eclipse and your user's $PATH should be used from now on. Also everything you have set up in ~/.bash_profile will run when opening a new Terminal in Eclipse.
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.
Had the same problem. Here is my solution:
Edit the
/etc/paths
file to include the desired additional path.For a OSX installation, run
/Applications/eclipse/eclipse
not/Applications/eclipse/Eclipse.app