Installing Java6 JDK on Ubuntu 12.04

UPDATE: [01-May-2012] It appears that this PPA repo is currently broken (does not allow to get GPG key and has unmet dependencies on x84_64). It appears that the install on i386 systems does work anyway if you ignore the GPG key error, but I wouldn’t install in that case as PPA installs are security risk enough without GPG errors.

UPDATE: [11-May-2012] The reason the PPA does not work is that it has been disabled by Ubuntu due to a licensing issue with (not hard to guess) Oracle. have however created a script (hosted on Github) to allow the automated update of Java 6 for those who still require it as a dependency.

wget -O
chmod +x
sudo ./

Hat tip to Martin Wimpress from Flexion !

UPDATE: [07-Aug-2012] Thanks to a comment from Pierre-Yves Langlois this seems to be the best method (uses the latest version of the Flexion script from Github rather than the version referenced above)

sudo apt-get purge sun-java* #You need to do that if you want the mozilla plugin to work without conflict with java7 for instance.
mkdir ~/src
cd ~/src
git clone
cd ~/src/oab-java6
sudo ./

Then when its finished, install java:
sudo apt-get install sun-java6-plugin sun-java6-jre sun-java6-bin sun-java6-jdk

You can follow the installation process with:
tail -f ~/src/oab-java6/

Note: If you do not need Java 6 it’s much safer to stick to the current Oracle Java 7 release.

This is an update to the Java6 install on 11.10 since the previous PPA repository has not been updated. To install on Precise Pangolin you need to add the following repository

sudo add-apt-repository ppa:flexiondotorg/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin

EDIT: [01-May-2012] since there seem to be many comments about the repo not working here’s the manual process (since I can’t find any working PPA that is actually maintained).

Download the Linux .bin install (32 or 64bit) from Oracle’s site Java Archive.

#change permissions to allow execute
chmod a+x jdk-6u[current_version_number]-linux-i586.bin
#run the installer file

Note: you obviously need to also maintain the Java6 updated manually.

Author: Leo Gaggl

ict business owner specialising in mobile learning systems. interests: sustainability, internet of things, ict for development, open innovation, agriculture

36 thoughts on “Installing Java6 JDK on Ubuntu 12.04”

  1. Its not working

    “Executing: gpg –ignore-time-conflict –no-options –no-default-keyring –secret-keyring /tmp/tmp.S76M7P9SkP –trustdb-name /etc/apt/trustdb.gpg –keyring /etc/apt/trusted.gpg –primary-keyring /etc/apt/trusted.gpg –keyserver hkp:// –recv
    gpg: “” not a key ID: skipping”

  2. Doesn’t seem to work for me. I get this confusing stuff:

    Executing: gpg –ignore-time-conflict –no-options –no-default-keyring –secret-keyring /tmp/tmp.R3lKxmFkgn –trustdb-name /etc/apt/trustdb.gpg –keyring /etc/apt/trusted.gpg –primary-keyring /etc/apt/trusted.gpg –keyserver hkp:// –recv
    gpg: “” not a key ID: skipping

  3. $ sudo add-apt-repository ppa:flexiondotorg/java
    [sudo] password for username:
    You are about to add the following PPA to your system:
    More info:
    Press [ENTER] to continue or ctrl-c to cancel adding it

    Executing: gpg –ignore-time-conflict –no-options –no-default-keyring –secret-keyring /tmp/tmp.VGrsnITKUy –trustdb-name /etc/apt/trustdb.gpg –keyring /etc/apt/trusted.gpg –primary-keyring /etc/apt/trusted.gpg –keyserver hkp:// –recv
    gpg: “” not a key ID: skipping

    Not working :(

  4. I get an error after executing this line: sudo ./

    during the step: “Downloading jdk-6u33-linux-i586.bin : http://: Invalid host name.”

    Any ideas? I went to the Github project site but did not see any issues listed related to this so it must be something I’m doing wrong.


  5. I am a near novice in Linux but just used the instructions from the second block above …
    sudo add-apt-repository ppa:flexiondotorg/java ….

    Result is immediate success – brilliant!
    The repositary must now be working again and downloads in my run of Synaptic where the appropriate files (sun-java6-bin, sun-java6-jdk, sun-java6-jre and sun-java6-plugin) are all shown as installed.
    Moreover, it runs the sometimes reluctant ADVFN monitor pages where my attempts with the officially offered java versions failed.

    For all that (and I digress) I find precise an obscure implementation of Ubuntu – it took me 20 minutes to find the Terminal! I much prefer hardy or lucid. They also appear to run a lot smoother/faster – probably more suited to my older machine.

  6. Renaming ‘precise’ to ‘oneiric’ in synaptic allowed me to use the ferramroberto ppa under lubuntu 12.04. While it is probably not the best way but at least it works. And for me it far better than messing with binary installers.

  7. modified at line 268 and following, forcing version 6 update 32, in this way:

    # Determine the currently supported Java version and update
    #JAVA_VER=`echo ${DEB_VERSION} | cut -d’.’ -f1`
    #JAVA_UPD=`echo ${DEB_VERSION} | cut -d’.’ -f2 | cut -d’-‘ -f1`

    this solved problem with “Downloading jdk-6u33-linux-i586.bin : http://: Invalid host name.”

    but download page needs authentication and package will not be downloaded via script.
    I’m trying to download package via normal browser and putting it into correct folder via scp.

  8. I have successfully installed java6 with Flexion github script without the error “http:// invalid hostname”. Here is what I did:

    sudo apt-get purge sun-java* #You need to do that if you want the mozilla plugin to work without conflict with java7 for instance.
    mkdir ~/src
    cd ~/src
    git clone
    cd ~/src/oab-java6
    sudo ./

    Then when its finished, install java:
    sudo apt-get install sun-java6-plugin sun-java6-jre sun-java6-bin

    You can follow the installation process with:
    tail -f ~/src/oab-java6/

    After that, when I do a “java -version” from the console, I get this
    java version “1.6.0_30”
    Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

    And visit the java test site to test the plugin:


  9. Hi

    Thank you for the solution.
    If I’m not mistaken the provided apt-get line in the final solution only install the JRE and not the JDK. I think that the correct install line should look like this:
    sudo apt-get install sun-java6-jdk


  10. Looks like a new version got pushed out and the script doesn’t properly support it. Script only works upto 6u33 but 6u34 is out now and script tries to download it but can’t.

  11. Currently on vers 6u35 you can replace in the script

    # wget${DOWNLOAD_INDEX} -O /tmp/oab-download.html >> "$log" 2>&1 &
    wget -O /tmp/oab-download.html >> "$log" 2>&1 &

  12. Pierre-Yves solution worked like a charm just yesterday.

    Nevertheless I wanted to share some advice. Please be sure to clean (or just wipe) the content of /var/local/oab before yo (re)start. In our case we ended in a very strange situation in which at least one of the .bin files from Oracle’s site was marked as downloaded successfully, but found appended to itself. We guess it has to do with “wget arguments”, but we could not investigate further at this time. From there, the build phase failed.

  13. why do you recommend installing

    sun-java6-bin sun-java6-jdk

    those aren’t listed in flexion instructions

    The _only_ reason I’m installing sun6 is for brother’s lametard Spawnscape / runescape

  14. @windows refugee on mint; The only reason for the sun-java6-jdk is that I generally need the JDK for my work. Should not be needed just for the runtime.

Leave a Reply