Tuesday, July 10, 2012

Oracle Java on Linux Mint 13 (32 & 64 Bits)

Linux Mint (which is based on Ubuntu) no longer distributes Oracle's (formerly Sun) Java JDK and JRE. Linux Mint & Ubuntu officially supports OpenJDK implementation of Java which is the base for Oracle's own implementation. However, if you want to use Oracle's Java 6 and/or 7, you can download them from Oracle's website. This article shows you how to install and configure both Java 6 and 7 alongside the OpenJDK versions 6 and 7 previously installed. I will also show you how to switch between the versions of Java installed.

Note that since Oracle Java is not officially part of Linux Mint, we cannot use the Synaptic Package Manager to search for and install the necessary packages (i.e., it is not part of the repository). We have to resort to using the command line to carry out installation. This also means that notifications on new versions (or updates) are to be done manually by visiting Oracle's website once a while to check for new updates.

To download Oracle's Java, visit their website at:


Navigate the site and download the following files for 32-bit Mint:


For 64-bit Mint, the following files need to be downloaded:


These are the latest versions (as of July 2012) available on the website. Note that the Java 6 JDK files are supplied in bin format while the Java 7 JDK files are supplied in tar.gz format. This means that we have to use different methods for installing them.

To install both the JDK 6 and JDK 7, follow the steps below. Note that the steps are for the 32-bit version of Mint. Replace the 'i586' portion of the filename with 'x64' for the 64-bit version.

  1. Open a terminal and change to the 'Downloads' directory:

    cd Downloads/

  2. Make the JDK 6 bin file executable by executing:

    chmod a+x jdk-6u33-linux-i586.bin

  3. Execute the JDK 6 bin file:


    This will create a 'jdk1.6.0_33' directory and all the files will be unzipped there.

  4. Unzip the JDK 7 file by executing:

    tar -xvf jdk-7u5-linux-i586.tar.gz

    This will create a 'jdk1.7.0_05' directory and all the files will be unzipped there.

  5. Unzip the JDK 6 and JDK 7 docs files by executing:

    unzip jdk-6u30-apidocs.zip -d jdk1.6.0_33/
    unzip jdk-7u4-apidocs.zip -d jdk1.7.0_05/

  6. Unzip the JDK 6 and JDK 7 demo & sample files:

    tar -xvf jdk-6u33-linux-i586-demos.tar.gz
    tar -xvf jdk-7u5-linux-i586-demos.tar.gz

  7. Now move the JDK 6 and JDK 7 directories to /usr/lib/jvm - it's 'proper' place.

    sudo mv jdk1.6.0_33 /usr/lib/jvm
    sudo mv jdk1.7.0_05 /usr/lib/jvm

  8. Now we need to tell the system that we have Oracle's JDK 6 and JDK 7 as alternatives to the OpenJDK. Of course, we can do this manually by using the 'update-alternatives --install xxx' commands for each item, but a far simpler method is to run a ready-made script to do this. The script can be downloaded by executing:

    wget http://webupd8.googlecode.com/files/update-java-0.5b

  9. Once the script file has been downloaded, execute:

    chmod +x update-java-0.5b
    sudo ./update-java-0.5b

    A dialog box will pop-up showing all the possible candidates - first, select JDK 6 and press 'OK'. The script will run, and make all the necessary changes for you. Now run the script again - this time select JDK 7 and press 'OK'. That's it - you now have OpenJDK versions 6 and 7 as well as Oracle JDK6 and JDK7 as alternatives. To check which Java is set as 'default', run the 'galternatives' utility. The display will look like the figure shown below.


  1. Nice post. To the point .Keep it up.

  2. I've been following your guide to the T, and it is remarkably easy to follow. However, point 7 and 9 need to be updated and simplified respectively. With point 9 I have no idea what I did nor if I did it correctly. For JDK6 I get three options while for JDK 7 I get two, no idea which one to pick. For JDK 6 I picked the first one and JDK 7 amd64 since the option for common didn't work. Does amd64 refer to the processor? I have an Intel.

    1. amd64 does refer to processor but Intel x64 chips get lumped with amd64 as amd was the first to release that 64bit extensions to the x86 architecture. If you see IA64 anywhere this is specific to the older Intel Itanium processors (defunct now)

  3. This approach seems a lot easier. Does it have any disadvantages compared to your approach?


    1. The method described there involves adding a ppa - if you are confortable with that, by all means use the method outlined there. The end result should be the same - you should have Oracle Java 7 correctly installed on your PC.

  4. Thanks for your help - this worked great for me on Mint 12.