If you have multiple executables of the same name available in the list of paths contained in your $PATH environment variable, your system will use the one it finds first.
Method 1: Set $PATH and $JAVA_HOME
I have multiple Java's installed on my system (JDK 2, JDK 5, JDK 6), but I configure my $PATH environment variable in my ~/.bashrc file so that I can choose the one I want.
Here is an example:
Every time I open a terminal it sets my path to exactly the same thing. If I change the value of the export JAVA_HOME line, and reopen a terminal, the new java is used.
# ~~~~~~~~~~~~~~~~~ JAVA (JDK,JRE) -----------------
Method 2: update-alternatives
The package managers are supposed to configure your system to give you the ability of choosing which java, too. The system it uses is update-alternatives. If you had multiple java executables, you should be able to choose the one you want to use by using the sudo update-alternatives --config java option. Whether or not you install from a package, it's possible to include your java among the choices available.