In Ubuntu, I'd like to switch my JAVA_HOME environment variable back and forth between Java 5 and 6.
I open a terminal and type in the following to set the JAVA_HOME environment variable:
Put the environment variables into the global
... export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun ...
Execute "source /etc/environment" in every shell where you want the variables to be updated:
$ source /etc/environment
Check that it works:
$ echo $JAVA_HOME $ /usr/lib/jvm/java-1.5.0-sun
Great, no logout needed.
If you want to set JAVA_HOME environment variable in only the terminal, set it in ~/.bashrc file. For More.