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.