I'm trying to change the value of $JAVA_HOME & I just can't seem to find in which file is it being set currently. I can't remember where did I set it the last time. Already tried How to determine where an environment variable came from? but I need(ed) a list of files where the variable can be 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.
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).