Installing Sun Java on Ubuntu Lucid

As of Ubuntu Lucid, the Sun Java JRE has been replaced with OpenJDK. Unfortunately, OpenJDK still isn’t a complete drop-in replacement for Sun Java. For instance, the Facebook “Upload Photos” applet doesn’t work correctly; the photos don’t have thumbnails and can’t be rotated before upload. The solution is to install the Sun Java JRE.

  1. Add the Canonical partner repository.
    sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
  2. Install Sun Java JRE.
    sudo apt-get update
    sudo apt-get install sun-java6-jre sun-java6-fonts sun-java6-plugin
  3. Update system defaults to prefer Sun Java over OpenJDK.
    sudo update-alternatives --set java /usr/lib/jvm/java-6-sun/jre/bin/java
    sudo update-alternatives --set javaws /usr/lib/jvm/java-6-sun/jre/bin/javaws
    sudo update-alternatives --set mozilla-javaplugin.so /usr/lib/jvm/java-6-sun/jre/lib/*/libnpjp2.so
  4. If that fails, manually choose them from a list. Always choose the option containing “java-6-sun”.
    sudo update-alternatives --config java
    sudo update-alternatives --config javaws
    sudo update-alternatives --config mozilla-javaplugin.so
  5. Restart Firefox.

Oh, happy coffee-cup-clock progress bar, how I missed you!

Tags: , , ,

  1. Tom Purl’s avatar

    Thanks for the tip! I had noticed that I was using the openjdk on my netbook, which was “upgraded” to 10.4 with a clean installation.

    Also, I noticed that my main computer had both Sun’s JDK and the openjdk. I upgraded this machine without re-installing the OS. Surprisingly, all of the java-related shortcuts were already pointing at the Sun version.

    Reply

    1. tyler’s avatar

      An upgrade won’t overwrite your /etc/alternatives preferences. By the same token, just installing the Sun JDK/JRE doesn’t make it the default JVM. Hence the update-alternatives commands.

      Reply

    2. Adam Schaible’s avatar

      Great guide, this is all the information I needed to replace Iced Tea with good ole Sun for those proprietary apps that refuse to run on Iced Tea.

      Thanks a lot!

      Reply

    3. adam’s avatar

      Thank you you are the first site to make this easy. I have been using Ubuntu since the beginning and this is the best instruction for Java.

      Do you perfer Netbeans, or Eclipse?

      Reply

    4. Rarsa’s avatar

      Succinct and easy.

      I’ll need to remember this when writing “How-to”s

      Thanks.

      Reply

    5. Will’s avatar

      OMG, you’re my HERO! I’ve been trying for literally months to get ONE website to work properly. Your fix took less than a minute, and works for both Firefox and Google Chrome. Thank you so much!

      Reply

      1. Tyler Wagner’s avatar

        I’m glad I could help, Will!

        Reply

Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.