I have both java 14 and 8 installed on my laptop but want to use 8 by default so I'm trying to set my JAVA_HOME to use -v 1.8.
In ~/.bash_profile I added the line export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
. Immediately after doing this echo $JAVA_HOME
returns the correct path and java -version
returns the correct version. However, if I close terminal and open it again, echo $JAVA_HOME
results in a blank line and java -version
shows java 14. After editing .bash_profile I did do source ~/.bash_profile
and when I reopen the terminal and do nano ~/.bash_profile
the line setting JAVA_HOME is still there. Why can't I permanently set it?