Yes, this is definitely possible.
Usually, I use symbolic links rather than having to change my environment settings
i.e. ln -s /usr/java/jdk1.3.1_03 jdk
So my PATH/JDK_HOME/JAVA_HOME is always ~/jdk, and I just change the symlink whenever I need to switch from 1.3.1 and 1.4.0 or whatever
I also do this on any winnt style platforms using the rather good "junction" command available from the always useful
www.sysinternals.com