Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Setting JAVA_HOME environment variable

When you type "echo $JAVA_HOME" in Mac, where does Mac look to find the value of JAVA_HOME? In other words where does Mac save environment variables?

share|improve this question

migrated from stackoverflow.com Jan 31 '11 at 19:47

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

marked as duplicate by Dennis Williamson, Mehper C. Palavuzlar, Sathya, Nifle Feb 3 '11 at 5:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Your question asks "where does OS X save environment variables?" Although the answers have discussed how to set variables, is this really what you're asking? If so, then the answer is "in the environment"! Each process (ie each application, and each command run from the command line) has an environment which stores, amongst other things, the set of variables. When you create a new process (for example you create a new terminal window, or run a new program) the new process gets a copy of the environment of the current process, including any variables you've set in that process. W –  Norman Gray Feb 2 '11 at 19:24

4 Answers 4

A similar question/answer was posted on stackoverflow. The solution describes that you should create a ~/.profile and define the environment variables at this level. You can check out the Apple Reference Library on setting environment variables for additional information.

share|improve this answer

In your home directory's .profile file. (ex: /Users/Mahdi/.profile)

share|improve this answer

Environment variables may be defined in all the usual places for a bash shell session. There is also an optional special file $HOME/.MacOSX/environment.plist which can contain environment variables for apps etc.

share|improve this answer

Put this: export JAVA_HOME=/Library/Java/Home (or location of your Java lib) in ~/.bash_profile

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.