May 29, 2009

Switching to Sun JDK/JRE/JVM in Ubuntu

Turns out, I've been using OpenJDK all this time. Apparently, this is not so bad, but when I tried to play with Ant from command line, I got BUILD FAILED kind of errors.

The symptoms are:

$ ant -version
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar
Apache Ant version 1.7.1 compiled on November 10 2008


$ java -version
java version "1.6.0_0"
OpenJDK Runtime Environment (IcedTea6 1.4.1) (6b14-1.4.1-0ubuntu10)
OpenJDK Server VM (build 14.0-b08, mixed mode)

The easiest way to solve this for me was to force Sun's “original” JDK.

Apparently, once you've installed sun-java6-bin, -jre and -jdk packages, you have to
$ sudo update-java-alternatives -s java-6-sun

and then edit /etc/jvm so that it looks something like this, with /usr/lib/jvm/java-6-sun on top:



Danny said...

I really hate that openjdk love that linux distibutions seem to have. Or even worse: gcj :-/ I thought people would abandon that stuff after the Sun JDK went Open Source, but noooo, let's keep torturing developers and users with required configuration and slightly incompatible JDK's, decreasing the chance of distributing a Java application that simply works.

sp said...

Well, wikipedia says, openjdk is the actual open source JDK from Sun. And I said that to force "original" JDK was the easiest way for me to solve my problems, so maybe it's not so much the issue of the openjdk as it's an issue of Ubuntu's poor JDK versions management (: