3
votes

I have looked all over the system and cannot find where the $JAVA_HOME environmental variable is set. It is not on ~/.bash_profile or ~/.profile, also it is not on the ~/Library/LauncherAgents files, but if I type echo $JAVA_HOME I get:

/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

So it is defined somewhere, but where? it is driving me crazy.

UPDATE

I was trying to install Maven, and had some problems, but not with the JAVA_HOME env variable, but still I added, just in case, the path to the Java directory to the .bash_profile file:

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/

Then I deleted it. And now whenever I try to print $JAVA_HOME I got nothing, it was like setting the variable in the bash_profile had an overriding effect wherever $JAVA_HOME was, so now everything is "normal". I mean, I need to declare the export statement for the $JAVA_HOME in the .bash_profile again to set Java. But before it didn't work like this, it was getting $JAVA_HOME from somewhere else !!!

1
Did you check /Library/LaunchAgents as well as ~/Library/LaunchAgents? Also check ~/.bashrc.James McLaughlin
Yes both checked, I have the environment.plist on the ~/Library/LaunchAgents but it is not there ! I don't have the ~/.bashrc file by the way.FraK
What about /etc/profile and /etc/bashrc? Or ~/.MacOSX/environment.plist (though this is apparently not used in Yosemite).James McLaughlin
Nothing there about JAVA_HOME.FraK
/etc/launchd.conf? Or /Library/LaunchDaemons (not agents)?James McLaughlin

1 Answers

0
votes

Find a list of files which include JAVA_HOME from the root directory:

cd /
find . -exec grep -Hn JAVA_HOME {} \;

References