Ubuntu – Best way to set JRE_HOME to Sun’s Java on Ubuntu 10.04

javatomcatUbuntuubuntu-10.04

I installed Ubuntu 10.04 which by default came with OpenJDK. I've since installed Sun's Java 6 using apt-get. When I type java -version I get:

java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

However, when I start Tomcat it still appears to using Open JDK.

Using JRE_HOME:        /usr/lib/jvm/java-6-openjdk

What's the best way to globally point to Sun's Java? Is there a way to uninstall Open JDK?

Best Answer

Have you looked at the update-alternatives command? You would use it like this: sudo update-alternatives --config java and then choose the version you want.

See the Ubuntu Java page for more details.

Hope it helps.