Thursday, July 11, 2013

Setting Environment Variables in OS X

Have you ever asked yourself What is the proper way to modify environment variables like PATH in OS X?
You could use:
/etc/paths
~/.profile
~/.tcshrc

OR you can try by playing around with
/etc/launchd.conf

Please note that environment.plist does not work for applications launched via Spotlight. This is documented by Steve Sexton here
  1. Open a terminal prompt
  2. Type sudo vi /etc/launchd.conf (note: this file might not yet exist)
  3. Put contents like the following into the file
    	#setenv JAVA_VERSION 1.6
    	setenv JAVA_HOME /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    
    	setenv ANT_HOME /Applications/java/tools/apache-ant-1.8.2
    	setenv ANT_OPTS -Xmx512M
    
    	setenv MAVEN_OPTS -Xmx1024M
    	setenv M2_HOME /Applications/java/tools/apache-maven-3.0.2
    
    	setenv ATG_HOME /Applications/java/tools/Dynamo5.6.1
    
    	setenv DYNAMO_HOME /Applications/java/tools/Dynamo5.6.1/home
    
    	setenv ORACLE_HOME /opt/app/oracle/product/817 
     
  4. Save your changes in VI and reboot your Mac.
  5. Prove that your variables are working by opening a Terminal window and typing export and you should see your new variables. These will also be available in IntelliJ and other GUI apps you launch via Spotlight.

No comments:

Post a Comment