Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from May 31 '10 at 3:28

This question came from our site for professional and enthusiast programmers.

Shouldnt this all be going in a plist for loading with launchctl? – prodigitalson May 30 '10 at 15:47
Do you mean environment.plist? I refer to this… 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 $ – al nik May 30 '10 at 17:48
@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. – prodigitalson May 31 '10 at 4:58

Try this instead:

export M2_HOME=/usr/share/maven
export M2=$M2_HOME/bin
export MAVEN_OPTS='-Xms256m -Xmx512m'
share|improve this answer
it won't work – al nik May 30 '10 at 17:42

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.

share|improve this answer

Hope this answer helps after all this time. You find a solution along your lines here. I think your problem is that the stuff in the third row, like $M2_HOME/bin or '-Xms256m -Xmx512m', is not expanded before it gets fed to launchctl. I provided another solution here.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .