Howto- Install Oracle Java7 in Ubuntu12.04 Precise Pangolin | PPA

The “Oracle-java″ package is no longer available in the official Ubuntu 11.10 Oneiric Ocelot and Precise Pangolin.   In this post i will show you how to remove OpenJDK and install Oracle Java7 on Ubuntu 12.04 Precise Pangolin.

First we need to remove the installed Open JDK Java:

sudo apt-get purge openjdk*

Now add the following PPA and install Oracle Java7 in Ubuntu 11.10, 12.04 Precise Pangolin:

sudo add-apt-repository ppa:eugenesan/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

I tested the above PPA in Ubuntu 11.10, 12.04 Precise Pangolin also on LinuxMint12 works just fine.

Please let me know if this worked for you. Thanks

  • Pedro Teixeira

    Got an error:

    Setting up oracle-java7-installer (7u3-0~eugenesan~oneiric4) …
    –2012-03-23 22:20:42–
    Connecting to||:80… connected.
    HTTP request sent, awaiting response… 302 Moved Temporarily
    Location: [following]
    –2012-03-23 22:20:42–
    Connecting to||:443… connected.
    HTTP request sent, awaiting response… 302 Moved Temporarily
    Location: [following]
    –2012-03-23 22:20:42–
    Connecting to||:80… connected.
    HTTP request sent, awaiting response… 200 OK
    Length: 5307 (5.2K) [text/html]
    Saving to: `./jdk-7u3-linux-x64.tar.gz’

         0K …..                                                 100% 1.68M=0.003s

    2012-03-23 22:20:42 (1.68 MB/s) – `./jdk-7u3-linux-x64.tar.gz’ saved [5307/5307]

    Download done.
    sha256sum mismatch jdk-7u3-linux-x64.tar.gz
    Oracle JDK 7 is NOT installed.
    dpkg: error processing oracle-java7-installer (–configure):
     subprocess installed post-installation script returned error exit status 1
    Errors were encountered while processing:
    E: Sub-process /usr/bin/dpkg returned an error code (1)

  • Micah Chen

    same here, using Mint, now every time i use apt-get command, there shows error message: 
    Setting up oracle-java7-installer (7u3-0~eugenesan~oneiric4) …Downloading…–2012-03-23 22:25:49–…, to||:80… connected.HTTP request sent, awaiting response… 302 Moved TemporarilyLocation: [following]–2012-03-23 22:25:49–… to||:443… connected.HTTP request sent, awaiting response… 302 Moved TemporarilyLocation: [following]–2012-03-23 22:25:49– to||:80… connected.HTTP request sent, awaiting response… 200 OKLength: 5307 (5.2K) [text/html]Saving to: `./jdk-7u3-linux-i586.tar.gz’     0K …..                                                 100%  243M=0s2012-03-23 22:25:49 (243 MB/s) – `./jdk-7u3-linux-i586.tar.gz’ saved [5307/5307]Download done.sha256sum mismatch jdk-7u3-linux-i586.tar.gzOracle JDK 7 is NOT installed.dpkg: error processing oracle-java7-installer (–configure): subprocess installed post-installation script returned error exit status 1Errors were encountered while processing: oracle-java7-installerE: Sub-process /usr/bin/dpkg returned an error code (1)

  • zinovsky

    Did you remove Java OpenJDK? I tested the PPA in Ubuntu 11.10, 12.04 Beta1 and LinuxMint12 and is working (See screenshots above)

  • Mohamed Khamlichi

     try  this  first
    sudo apt-get install -f

  • Enkouyami

    It would be good if you also included that you can get the JRE, JDK, and plugin after getting the ppa with theres: oracle-java7-jre, oracle-java7-jdk, oracle-java7-plugin

  • Artis Eisaks

    i don’t know why, but when i typed in the “sudo apt-get install oracle-java7-installer” and pressed enter, it showed me this:
    “E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)
    E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?”
    put on a new post about this problem, please?

  • AliusPanfilovas

    Same here, did you noticed this line: ‘sha256sum mismatch jdk-7u3-linux-x64.tar.gz’?

  • Lucas Mezêncio

    I am having the same problem.. =//

  • Wiley

     Same here.

  • AliusPanfilovas

    OK figured out how to install.
    Download tar.gz from here:
    and place it to: var/cache/oracle-java7-installer
    then open with text editor: var/lib/dpkg/info/oracle-java7-installer.postinst
    and place # (or delete) in beginning of these lines: 74-107, 111-116
    and then run again sudo apt-get purge openjdk*

  • Sahat Yalkabov

    I followed all the steps, still the same error.

  • AliusPanfilovas

     Obviously you didn’t, because ‘#’ disables those lines and those lines are downloading and verifying archive…
    from 74 to 107 and from 111-1116

  • oozgurozkan

    Same error is here but there is no var/lib/dpkg/info/oracle-java7-installer.postinst file. 

  • AliusPanfilovas

     Search for it, mine is Linux Mint 12 x64, might be in different location.

  • sharp_coder

    There is no need to edit the file, it was just written in a bad way and i really dont feel like editing it so heres the easy peasy way….

    1. just add the ppa mentioned in this blog and install it and i m sure u will get an error at the end of the installation but dont worry just close the synaptic or watever u used to install it.
    2. download the latest JAVA JDK7 from this link and unzip it anywhere u want to ( i prefer desktop )…again download JDK not JRE
    3. now open ur terminal and issue the command called ” sudo nautilus ” (without quotations) once ur nautilus is opened in root mood, navigate to the directory usr/lib/jvm and yes u can find usr directory by clicking on the filesystem on ur menu on the left side of nautilus.
    4. u will see a java7-oracle folder in that navigated directory, go ahead and double-click on that
    5. now open another nautilus window (u dont need to run this in root mood just open it by clicking on download or pictures folder) and DONT close the other nautilus window which u open through terminal.
    6. now remember the file u downloaded and unziped it (wherever u did, i preferred desktop), go IN that unzipped folder with the new nautilus window and copy all of its contents ( NOT the whole unzipped folder itself but its contents inside it ok? sure u got it? gud)
    7. copy all those contents into the java7-oracle folder which u navigate to with the terminal nautilus window….. thats it u r doneee….go ahead and open ur “unity lens” and type oracle and click on any java 7 and it workss…

    hopefully that was user friendly enough?

  • Onur

    After moving the file and stuff… 
    What he means is that when you open the text document, locate the designated lines (74-107, 111-116) first (know which sentences etc.) and THEN delete them. This does not mean that first delete 74-101 and then locate 111-116 to delete cause when you do that you are doing the first delete correctly but the second time the lines between 111-116 are wrong as they are moved to above after your first delete. I hope I am clear?After you delete that. go to your software center, click on installed arrow to select JAVA and then uninstall java 7. Then restart. This is how you get rid of java7 on ubuntu 12.

  • Clayton Casciato

    This is CRAP. It jacked up my system so bad (I got the same errors as reported by Pedro Teixelra. Couldn’t get it to work) Use this instead (it works with no errors) :

    sudo apt-get purge openjdk*
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java7-installer

    The original installer screwed up apt. Would give an error and prevent certain apt capabilities. Use the above to have no issues. Enjoy!

  • Memedai

     You saved my live. thx.

  • joe

     NO luck  here  ….. Heeeelp !!??

  • AliusPanfilovas


  • lucasmezencio
  • Strofo

    Thanks for the help. Work like a charm.

  • Digitalelixir

    dude edit your article. The repository is broken

  • Aldous Robles

    sha256sum mismatch jdk-7u3-linux-x64.tar.gz error:

    try this;

    sudo rm /var/lib/dpkg/info/oracle-java7-installer*
    sudo apt-get purge oracle-java7-installer*
    sudo rm /etc/apt/sources.list.d/*java*
    sudo apt-get update
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java7-installer

  • Dielan

    This is great but when I right click on my minecraft.jar launcher I don’t have an option to run in java runtime environment. It only works through the command line.

    help? I’m running LMDE and up to date with the 201204 installation.

  • John McLellan

    worked for me 

  • Mciglesiass

    ufff…thanks very much

  • Author

    thx man :D

  • guest

     Thanks! it was driving me nuts

  • guesT

    really really helpfull and easy way around. i cannot fully understand what those commands did but anyway thanks a lot.

  • Guest

    after installation can i remove the file in   /var/cache/oracle-jdk-installer/ i.e the tar.gz of jdk

  • Andrew

    Thank you so much. After googling unsuccessfully for about half an hour, this did the trick!

  • Temple Pate

    I have tried to install it again. It worked wonderfully the first time, but now I am getting the same response as Aldous. Please help.

  • Guest

    Thanks very much, worked like a charm.

  • Kog Siege

     im new to ubuntu, where the hell can i enter these codes? i cant see any dropdown menus in desktop, my access to system is very limited…err..please help..

  • Ahmed Hegazy

    worked !
    thank you

  • Jesse Gaspar

    Thanks, bro. I was working on it.

  • xdc

    thanks Worked Here, on Linux Mint Maya.
    java -version
    java version “1.7.0_06”
    Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
    Java HotSpot(TM) Server VM (build 23.2-b09, mixed mode)

  • JAck

    Do Ctrl+Alt+T

  • guest

    Your solution worked great. Thanks a bunch!

  • sid

    thanks man!! was of great help.

  • Cetaphil

    Cool article, It was funny.