Defining system variables in Mac OS X

Submitted by Jochus on Tue, 23/10/2012 - 17:07 | Posted in: Mac


If you want to define a system variable in Mac OS X, and you want all of your applications (commandline, GUI, ...) to be able to pick them up - then you need to follow the steps:

  • Open a terminal
  • Execute the command:
    $ sudo nano /etc/launchd.conf
    Remark: In my case, the file didn't exist, so don't worry if you need to create it
  • Insert the following text (I added 2 examples: JAVA_HOME and JREBEL_HOME)
    # Set environment variables here so they are available globally to all apps
    # (and Terminal)
    #
    # After editing this file run the following command from the terminal to update 
    # environment variables globally without needing to reboot.
    # NOTE: You will still need to restart the relevant application (including 
    # Terminal) to pick up the changes!
    # grep -E "^setenv" /etc/launchd.conf | xargs -t -L 1 launchctl
     
    setenv JAVA_HOME /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    setenv JREBEL_HOME /Applications/eclipse/plugins/org.zeroturnaround.eclipse.embedder_5.0.1.RELEASE-201207191833/jrebel

Add new comment

The content of this field is kept private and will not be shown publicly.

Full HTML

  • Lines and paragraphs break automatically.
  • You can caption images (data-caption="Text"), but also videos, blockquotes, and so on.
  • Web page addresses and email addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <cpp>, <css>, <html5>, <java>, <javascript>, <php>, <sql>, <xml>. The supported tag styles are: <foo>, [foo].
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.