How to Install Sun Java 6 on Ubuntu

For some reason, Canonical has decided to default to OpenJDK for Ubuntu 10.04. This would be fine if they didn’t also bury the option to use Sun’s JDK way deep in the Interwebz where its not easily found. Here’s how to get the real JDK in case you care about stuff like compatibility or stability or whatnot…

Add the following lines to /etc/apt/sources.list:

Then issue the following commands:

sudo aptitude update
sudo aptitude install sun-java6-jdk

You will have to accept the license agreement dialog, as is normal for installing Sun’s JDK. Then, in order to use Sun’s JDK, issue the following command:

sudo update-java-alternatives -s java-6-sun

You should then be good to go.