Are Sun's Java 6 and OpenJDK 6 interchangeable? Check for yourself.

Printer-friendly versionPrinter-friendly version

Occasionally, when running Linux (and I'm doing this in the context of a 64-bit install of Ubuntu 10.04), you'll run across software that claims to officially support only Sun's Java, and not the standard OpenJDK that comes with Ubuntu (and, of course, other Linux distros). Do you need to take that warning seriously? Why not test it for yourself?

Again, working within the context of my Ubuntu system, install both the Sun Java 6 JDK and OpenJDK 6:

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk openjdk-6-jdk

now check which one is currently "active":

$ java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)
$

That's telling you that, at the moment, all invocations of Java will use Sun's JVM, but you can switch back and forth using the update-java-alternatives command.

First, list all of the JVM alternatives:

$ update-java-alternatives -l
java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk
java-6-sun 63 /usr/lib/jvm/java-6-sun
$

At this point, you can switch to using OpenJDK and verify that that's the new active JVM:

$ sudo update-java-alternatives -s java-6-openjdk
update-alternatives: error: no alternatives for mozilla-javaplugin.so.
update-alternatives: error: no alternatives for xulrunner-1.9-javaplugin.so.
update-java-alternatives: plugin alternative does not exist: \
 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/IcedTeaPlugin.so
$

And, yes, it's entirely possible that you'll get some errors since you might still need to install related packages to go along with whatever JVM you selected, but you can verify that you're now using your newly-selected JVM:

$ java -version
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-4ubuntu3)
OpenJDK 64-Bit Server VM (build 16.0-b13, mixed mode)
$

At this point, resume running your software and, if it seems to work fine, you can continue using OpenJDK. If not, just switch back to Sun's Java.

We know

We're aware of the time and budget pressures at most companies, normally accompanied by the plaintive cry from management of, "Yes, I know we need training on that topic, but I just can't afford to send my entire team away for three (or four or five) days to get it!" And that's where we come in.

Choices!

The main focus at Crashcourse is to offer a choice of intense, 1-day, hands-on courses on specific topics in Linux and open source. And given that we already have the laptops for the delivery of that training, the idea is to show up early, set up a classroom, then spend the day teaching exactly the topic you're interested in. No travel time, and no wasted classroom time.

Customization

If we don't already have a course that addresses the topic you're interested in, drop us a note and we'll see what we can do -- our content providers can almost certainly put together a course that's precisely what you're after.

The difference

While there are a variety of sources for Linux and open source training, we at Crashcourse are taking a slightly different approach. Our philosophy is simple: exactly the training you want, and no wasted time or travel to get it.