Installing Java 6 JDK on Ubuntu

October 3, 2010

None of the posts I found on this worked quite right, so I’m writing up what I did here for future reference.


sudo apt-get update
sudo apt-cache search java6

When I did this, the results I got included:


default-jdk
default-jre
default-jre-headless
openjdk-6-jdk
openjdk-6-jre
openjdk-6-jre-headless

If I’m interpreting it right, that means the Sun JDK is not available for installation via apt-get, at least the way I have it configured. But people said that the OpenJDK works fine too. So I decided to install it. It seems that specifying “default-jdk” just installs “openjdk-6-jdk” anyway:


sudo apt-get install default-jdk

When this completed, /usr/bin/java was set up for me. But I did have to add a JAVA_HOME environment variable to my .bashrc file:


export JAVA_HOME="/usr/lib/jvm/java-6-openjdk/jre"

After that, I was set to go.