2

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.

JFPicard
  • 5,029
  • 3
  • 19
  • 43
Jenny
  • 107
  • 2
  • 11
  • As you can see /usr/local/bin is already in $PATH from terminal, but not in JAVA from eclipse. – Jenny Dec 01 '15 at 14:15

2 Answers2

0

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

Community
  • 1
  • 1
Jenny
  • 107
  • 2
  • 11
0

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.

Community
  • 1
  • 1
Jenny
  • 107
  • 2
  • 11