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?

link|improve this question

25% accept rate
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
feedback

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

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

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

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

4 Answers

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.

link|improve this answer
feedback

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

link|improve this answer
feedback

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.

link|improve this answer
feedback

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

link|improve this answer
feedback

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