I had a situation yesterday where I needed to have the value of an environment variable visible within my IDE, which currently happens to be IntelliJ IDEA. My operating system for this environment is OSX (on a Mac), so my first instinct was to set the variable in my .profile.
This works fine for applications I launch from a Terminal window using the shell – such as Maven or Ant.
Unfortunately, IntelliJ didn’t “see” the variable at all, as it’s launched as a regular Mac application (from my Toolbar or as an application in the Applications folder). As I was accessing the variable from within a Maven POM file within IntelliJ, it was polite enough to highlight it in red. The same POM file worked fine from the command-line, but of course that’s because the variable was being set within my .profile, so the shell could “see” it.
My second instinct was to put it in /etc/profile, in the *nix fashion, but this didn’t work either.
A bit of googling found the answer, though. I created a file called “launchd.conf” in the /etc directory. (You’ll need to use “sudo” to edit this file, e.g. “sudo vi /etc/launchd.conf”)
In this file I can add “setenv” commands to establish values for the environment variables I need. In this case, I needed to specify a variable to tell my Maven build files (which I use from inside IntelliJ) where my Weblogic installation resides, so I did:
setenv WL_HOME /Users/mnash/bea/wlserver_10.3<br />
Then I reboot, and voila, my variable value is now available both from a command window and from within IntelliJ.
Thought I’d pass this along.
My thanks to this article for the information about launchd.conf.