I believe up until Yosemite, I didn’t have issues setting up environmental variables (i.e. JAVA_HOME) via my .bash_profile. As I upgraded, that no longer worked, so I found another way: use a custom .plist in your LaunchAgents folder:
- Go to ~/Library/LaunchAgents
- Add something like the below and then reboot, or unload-load it via launchctl unload
- That’s it!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>my.startup</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>launchctl setenv APPS_CONFIG '/Users/anton/box/Source/apps_config' | launchctl setenv CATALINA_BASE '/usr/local/Cellar/tomcat7/7.0.63/libexec' | launchctl setenv CATALINA_HOME $CATALINA_BASE | launchctl setenv HOMEBREW_GITHUB_API_TOKEN 'b20aeb90b4d0cbc8352bdc6059073b7be473e4e3' | launchctl setenv JAVA_HOME '/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/' | launchctl setenv M2_HOME $'/usr/local/Cellar/maven@3.2/3.2.5/libexec' | launchctl setenv GATLING_HOME '/usr/local/Cellar/gatling/2.1.7/'</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>