Friday, November 27, 2009

Mac OS X environment variables + Netbeans + Maven

Applications that are not launched through your terminal in OS X do not read environment variables from ~/.profile, ~/.bash_profile and similar. These applications that launch directly can get their environment from each user's ~/.MacOSX/environment.plist file. ( You have to create it!)

I heard of this before, but I wanted to make note of a quick way to ease the maintaining of that file and finally had a need because of Netbeans.
  1. Downloaded Brian D Foy's Perl plist lib and installed it.
  2. Used a 3 line script to generate the ~/.MacOSX/environment.plist file from my terminal's ENV variable as he suggested.
  3.  Log out and log in for the file to take effect.
Now I can be sure the PATH that Netbeans sees is the same thing that mvn and other tools are seeing when I execute them on the cmd line. Also I don't really have to worry about maintaining my env in two places as one is derived from the other.

Technical Q&A QA1067: Setting environment variables for user processes
Helpful Summary of other ways to set env variables in OS X
Brian D Foy's Perl plist reader lib and blog post
Netbeans documentation on working with OS X Environment variables

Another method is setting environment variables inside your
file as described here - there are clear benefits to this for apps launched outside your personal login.

1 comment:

for ict 99 said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training in India . Nowadays Java has tons of job opportunities on various vertical industry.

Post a Comment