Which Java?
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:
Code:
# ~~~~~~~~~~~~~~~~~ JAVA (JDK,JRE) -----------------
export JAVA_HOME='/usr/lib/Java6'
PATH=$JAVA_HOME:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:'/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin'
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.
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.
Bookmarks