Installing Java on Ubuntu Lucid or Maverick

Sun Java 6 is missing from a standard Ubuntu Lucid or Ubuntu Maverick installation, as well as missing from all of the APT repositories that come prepackaged with Ubuntu – including metaverse, universe, or any other.

Apparently, with the release of Ubuntu 10.04 Sun Java moved to the Canonical Partner repository. This means that to get Sun Java, you have to add the Canonical Partner repository to your list of APT repositories:

sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"

If using Maverick, then replace “lucid” with “maverick”:

sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner"

Then update your APT cache and install:

sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin

Once this is done, Sun Java is installed. However, Sun Java is not set as the default Java to use. To make this change, use update-alternatives:

sudo update-alternatives --config java

With the appropriate selections, this should configure Sun Java as the default Java for applications to use. Browsers will have to be restarted to activate the new Java plugin.