Saturday, February 06, 2010

Manually updating Ubuntu system alternatives

I like to have the freedom to install the latest Java releases without waiting for them to be available as an Ubuntu package. The problem is, if you manually install java, you need to update Ubuntu's update-alternatives framework so that other components which use java can be made aware of the new version.

Assuming you just downloaded jdk1.6.0_18 and placed it in opt. Here's how to do it:

sudo update-alternatives --install java java /opt/jdk1.6.0_18/bin/java 1
sudo update-alternatives --config java

I might have screwed up my update-alternatives configuration for java, but I had to repeat this process for all the java executables that update-alternatives tracks.

I got a list of them using:

ls -l /usr/bin | grep java

And then performed the same two steps to set each one to use the jdk1.6.0_18 version.

There's also a good article on the Java site about manually updating the Java Firefox plugin:

The Ubuntu update-alternatives utility can also be used to set the Firefox java plugin:

sudo update-alternatives --install /opt/jdk1.6.0_18/jre/lib/amd64/ 1
sudo update-alternatives --config