add /usr/local/bin to $PATH got from System.getenv("PATH") in JAVA run on MAC OS

I manually installed a software which is under /usr/local/bin. I want to use it in Java. But when I use System.getenv("PATH") to get $PATH. it doesn't include /usr/local/bin. How to solve this problem?

$PATH I got from terminal:

/opt/local/bin:/usr/local/maven/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin

$PATH I got in JAVA run from eclipse:

/usr/bin:/bin:/usr/sbin:/sbin

My /etc/paths is like this:

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

My ~/.bashrc is like this:

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

There is no content in ~/.bash_profile.

Answers


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

https://serverfault.com/questions/16355/how-to-set-global-path-on-os-x/277034#277034


Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan

the answer "Create an environment.plist file in ~/Library/LaunchAgents/" doesn't work for me. In OSX 10.10.5 Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra?

Using this method, works for setting other variables but not for PATH. I have tried.


Need Your Help

How do I add my twitter fabric timeline ListFragment to my activity in Android Studio

android android-fragments twitter android-listfragment twitter-fabric

Im making a twitter client for android and Im having a hard time adding the list fragment for timelines (fabric) to my activity. At first it would crash my app but now Ive made a few changes and it

PrimeFaces custom text on Menubar

jsf jsf-2 primefaces

I am using <p:menubar>. I've seen that I can use 'facet' to render custom content, like shown in the showcase.