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 !!!