$ which java | xargs file
/usr/bin/java: symbolic link to `/etc/alternatives/java'
$ file /etc/alternatives/java
/etc/alternatives/java: symbolic link to `/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java'
Here in this case we are looking at the java pointing to the one bundled by openjdk. Say if you have installed the Sun (or Oracle rather :|) JDK and if the path to that is /opt/java/bin , then you can add the sun version of java to the alternatives system using :
$ alternatives --install /usr/bin/java java /opt/java/bin/java 100000
The last number there is a priority, set it high so that any priority based overrides are ineffective. Now by doing :
$ alternatives --config java
you should be able to switch between the alternative versions of java !