Sunday, July 29, 2012

Updating Java on Mint (and Ubuntu)

For various reasons, including compatibility issues with some third-party programs and a need to generate cross-platform code on occasions, I routinely use Sun (now Oracle) Java on Linux systems, rather than GCJ (which is frequently included in Linux distributions). Following a suggestion in a recent email from the folks at Mozilla, I checked my Firefox plugins and discovered a security warning for the Java 6 plugin. I'm not sure if I could upgrade just the plugin, using the Java 7 browser plugin while still using the Java 6 JRE (runtime environment) and the Java 6 JDK (development kit); so I decided to upgrade everything to Java 7. Small problem: the Ubuntu repositories still contain version 6 and not version 7.

A quick search turned up a blog post at Web Upd8 which explains why the official repositories lag behind:
Oracle JDK7 itself is not hosted in the PPA because that's not allowed by the new Java license (which is also the reason why it has been removed from the official Ubuntu repositories); the package in the PPA automatically downloads (and installs) Oracle Java JDK 7 from its official website and installs it on your computer, just like the flashplugin-installer package does.
The PPA (personal package archive) repository to which they refer contains a package that automatically downloads and installs the current version of the Oracle Java 7 JDK. (Note that there is no comparable package to install just the JRE; you have to install the full JDK, which contains the JRE as a subset. That's fine with me, since I need the JDK for program development.)

The instructions are straightforward and worked fine for me. Once I had confirmed that Java 7 was installed and was the default choice, there was one more step. I use the Netbeans IDE for writing Java code. I could have installed the latest version with Java 7 bundled, but that's a hefty download, and my current version of Netbeans is recent enough. In Netbeans, I clicked Help > About and discovered that Netbeans was still launching with Java 6. The solution is to edit the configuration file <netbeans>/etc/netbeans.conf (where <netbeans> is the top directory of the Netbeans installation) and change the setting for netbeans_jdkhome to point to the Java 7 directory. When I restarted Netbeans, it launched with Java 7 and also changed the default Java platform for compiled code to Java 7.

Big thanks to the PPA maintainers for simplifying the process.


  1. Oracle has discontinued the "Operating System Distributor License for Java" (DLJ) [] plan in 2011; Ubuntu users now get their daily dose of coffee via

    sudo apt-get install openjdk-7-jdk
    sudo apt-get install openjdk-7-jre
    sudo apt-get install icedtea-plugin


    1. Yes, you should use OpenJDK instead of Oracle's implementation. Wikipedia says: "As of Java SE 7, OpenJDK is the official Java reference implementation."

      I think since Java 7, Oracle's implementation and OpenJDK are mainly the same.

      Best regards,

    2. Florian and Thomas: The key here is "mainly the same". I have a couple or so programs I wrote that I share with other people (open source). They have GUIs written using Swing, and they need to run cleanly on multiple platforms (Linux, Mac and Windows). For very small values of $\epsilon$, $(100-\epsilon)\%$ of Windows users that have Java have the Sun/Oracle version. Can I safely assume that OpenJDK's version of Swing is fully compatible with Oracle's? If so, and assuming no key language features are missing, I'd be happy to switch to OpenJDK.

    3. Continuing previous comment: I just found this page which seems to indicate that there are problems using Swing with OpenJDK apps on OSX. I think I'll stay with the Oracle version for now, but hopefully the kinks in Swing on OpenJDK will be ironed out soon.

    4. First of all, since OpenJDK 7 is the _official_ Java SE 7 reference implementation [], its behaviour is by definition the default behaviour.

      Furthermore, Oracle's JDK7 basically is nothing more than an OpenJDK release [] w/ web browser plugin and Web Start technology [] - here, IcedTea comes into play ...which is certified "Java compatible".

      (Reported compatibility issues mainly refer to v6 - since they had different code bases.)

      In fact, there's a big advantage of using OpenJDK over Oracle's JDK: you can distribute OpenJDK with your implementation - which you can't do with Oracle's JDK (and there are 33 releases of v6 and 5 of v7).

  2. +1 on fbahr's comment.
    OpenJDK 7 + Web Start + browser plugin == Oracle JDK 7
    However, this was not the case for Java 6:
    OpenJDK 6 + Web Start + browser plugin != Sun (= Oracle) JDK 6
    because the Sun JDK 6 contained a bunch of proprietary third-party code, most notoriously for fonts (which are important for Swing to run correctly).

    1. I bow to the consensus. :-) Unfortunately, I'm running Mint Katya, forked from Ubuntu Natty, and OpenJDK 7 does not seem to be available for Natty. (As best I can tell, packages start with Oneiric.) One of these days I'll upgrade to a more recent Mint release, at which time I should be able to install OpenJDK 7. For now, I'll muddle along with the Oracle version.

      Thanks all for the comments. The clarification was quite helpful.

    2. Oh, yes, you're right ...looks like OpenJDK7 is only available for "Oneiric Ocelot" (11.10) and newer:


Due to intermittent spamming, comments are being moderated. If this is your first time commenting on the blog, please read the Ground Rules for Comments. In particular, if you want to ask an operations research-related question not relevant to this post, consider asking it on Operations Research Stack Exchange.