Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.)

share|improve this question
add comment

6 Answers

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
add comment

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/Eclipse.app

share|improve this answer
    
omg number 2 on here was the solution to SO MUCH FRUSTRATION. Thanks!! –  Tommy Oct 2 '13 at 16:39
add comment
up vote 2 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

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin

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  
+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
add comment

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
add comment

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
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.