How To: Install the official Oracle JRE/JDK in Linux

Installing the official Sun/Oracle Java implementations used to be as easy as installing sun-java6-* and uninstalling all the OpenJDK and IcedTea (Java plugins based on OpenJDK) packages you could find – but you can’t get the offical “Sun” packages anymore, instead you have to go get the binaries from Oracle (who bought Sun Microsystems). You can take a swiz at the possible Java implementations here if you like.

Anyways, to get and install the official JRE or JDK (I’ll assume that most people aren’t going to be developing in Java so only want the Runtime Environment and not the full Development Kit):

  1. Head on over to: and download tar.gz version of the latest JRE, which at the time of writing is 1.7 update 7 (i.e. 1.7.0_07, the Linux 64-bit version of which is called jre-7u7-linux-x64.tar.gz),
  2. Extract the downloaded archive through any way you see fit. I’ll assume you downloaded it to your Downloads folder and extracted it there for the following commands,
  3. Create a new folder for it wherever your distro likes to put Java installs, for example:
  4. Move your extracted JRE to that location using:
  5. Update your alternatives to prefer the new version of java by running (one line at a time):

    If you’re installing the JDK you’ll prolly want to set the javac (Java Compiler) binary to the new version too using:

    The number at the end of the line is the priority of this binary out of any other java/javac/javaws binaries alternatives knows about, and goes from 1 (most important – try to use first) to 100 (least important – use only as a last resort)

  6. To make sure that the update-alternatives commands take, you can also run (again, one line at a time):

  7. Finally, to check it all really took, issue:

    and you should see some output showing that the newest version of Java is in effect, like this:

Done & dusted.

How-To: Install the Official Sun JDK in Ubuntu

Update: I wrote this to switch out the JRE in Ubuntu 10.04, and it’s still valid & works in Ubuntu 10.10 =D

The default java solution for Ubuntu 10.04 is the OpenJDK virtual machine and the IcedTea plugin for firefox – but I’ve been having serious issues with it locking up, taking up 100% CPU and other such craziness – so I’ve switched over to the (proprietary) official Sun JDK, and things are working much better. Here’s how I did it, and how you can too…

1.) Add the Lucid Partner repository to your Sources list

We’re going to be installing the Sun JDK through the repos, and it just so happens that we need the partner repo enabled, so you can either add the following line to your /etc/apt/sources.list, or you can check the box in System | Administration | Software Sources (assuming you’re using Gnome – pick whatever source managing front-end KDE uses if that’s your poison):


Sun JDK Add Repo

2.) Install the Sun JDK and Plugin

Before you install the good stuff, it’s an idea to check your current version so you can see the changeover’s worked. To do this, just run java -version from bash and you should see something like this:

Once you know what you’ve currently got, again from the shell, enter the following to install the official Sun JDK (don’t worry about multiple JDKs being installed – we deal with that later):

During this process you’ll have to agree to the license agreement – just hit Tab to switch focus in the text window onto the Yes button (assuming you do agree), and hit Enter to accept.

The JRE EULA - Slap the Tab key followed by Enter to ensure swift installation and that Oracle (they bought Sun, remember?) now own your first born child...

3.) Remove the old OpenJDK stuff

In Synaptic, you want to fully remove the following packages (if they’re installed – the top three in the below list might not be):

If you do this before installing the Sun JDK, all packages depending on Java will be removed as well – so in this rare instance, later is better, and any packages depending on Java can now stay on the system.

4.) Check it all works

From the command line enter: java -version and you should see the new details:

If you want the new plug-in to take effect in Firefox or such you need to restart the browser, then you should be all good to go! Maybe test it out at sodaplay for kicks too :)