Here is a shell script designed to work on Centos and Ubuntu, to establish
the JAVA_HOME and JRE_HOME variables.
Some of the requirements were that for Centos 5, we default to /usr/bin/java,
and for Centos 6 we should default to whatever the alternatives java link points to.
It will work for Ubuntu as well, perhaps with some extension.
UPDATE: the old script failed on Centos 7 - this fixed it.