How to find where is $JAVA_HOME set?
You didn't specify a shell. So, I will assume bash
. The next issue is: did you set it for your user only or system-wide? If you set it for your user only, then run:
grep JAVA_HOME ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc
If you set it system-wide, then it may vary with distribution but try:
grep JAVA_HOME /etc/environment /etc/bash.bashrc /etc/profile.d/* /etc/profile
If the above give no answer, you can cast a wider net:
grep -r JAVA_HOME /etc
grep -r JAVA_HOME ~/
See also the suggestions in How to determine where an environment variable came from.
With zsh
:
zsh -xl
In bash
:
PS4='+$BASH_SOURCE> ' BASH_XTRACEFD=7 bash -xl 7>&2
That will simulate a login shell and show everything that is done (except in areas where stderr is redirected with zsh
) along with the name of the file currently being interpreted.
So all you need to do is look for JAVA_HOME
in that output. (you can use the script
command to help you store that output).