Setting environment variables in OS X /etc/launchd.conf

7,480

Solution 1

While I realize that there are many ways to go about this. If one is just interested in configuring environment variables for IntelliJ then you could do the following without going through a lot of hassle:

IntelliJIDEA -> Preferences -> Path Variables

Now select Add on the right and add your required variables. In my case it is the following as I used homebrew to install Maven:

Name: M2_HOME
Value: /usr/local/Cellar/maven/3.0.4

Now look under IntelliJIDEA -> Preferences -> Maven and everything should be automatically configured. Select OK and now you should be all set. Just so you guys know I use IntelliJ IDEA 11.

Be advised that the above will work only in IntelliJ. If you want this in terminal, put the required stuff in .bash_profile or throw it in /etc/launchd.conf if you want this for GUI's and the terminal. You can find more info on these methods easily doing a quick search.

Solution 2

Try this instead:

export M2_HOME=/usr/share/maven
export M2=$M2_HOME/bin
export MAVEN_OPTS='-Xms256m -Xmx512m'
Share:
7,480

Related videos on Youtube

al nik
Author by

al nik

Updated on September 17, 2022

Comments

  • al nik
    al nik over 1 year

    I'm trying to set some env variable in OS X 10.6 (/etc/launchd.conf)

    setenv M2_HOME /usr/share/maven
    setenv M2 $M2_HOME/bin
    setenv MAVEN_OPTS '-Xms256m -Xmx512m'
    

    M2 and MAVEN_OPTS are not working.
    I tried with something like

    setenv MAVEN_OPTS -Xms256m\ -Xmx512m
    

    but still it doesn't work. Any idea of what is the correct synthax?
    Thanks

    • asj
      asj almost 14 years
      Shouldnt this all be going in a plist for loading with launchctl?
    • al nik
      al nik almost 14 years
      Do you mean environment.plist? I refer to this stackoverflow.com/questions/135688/… it says 'environment.plist does not work for applications launched via Spotlight' so I was trying to set the env variables using launchd.conf. It works fine. But It won't work using spaces or if I concat variables using $
    • asj
      asj almost 14 years
      @al nik: no not environment.plist. i mean a plist to use with Maven as a service - if youre trying to run this as a background service (daemon) then you should be crafting your own plist to launch the daemon and this data would go there. I see from your response below that youre trying to get this var hooked up in IntelliJ instead im guessing? If thats so then i would look for a way to set variables withing IntelliJ. I dont know if it provides this but i know Eclipse does so i would assume there is something similar.
  • al nik
    al nik almost 14 years