Ubuntu: Fix for Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar

Ran into this nasty error today while trying to build irccat. ¬†Perhaps you’ll see something like this at the end of the output as well:

BUILD FAILED /home/lucas/irccat/build.xml:22: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to "/usr/lib/jvm/java-6-openjdk/jre"

Get the Sun JDK sudo apt-get install sun-java6-jdk then run sudo update-alternatives --config java and select the option that has the path /usr/lib/jvm/java-6-sun/jre/bin/java

No more errors.