10

I'm trying to install JDK7 on ubuntu 12.4.

In the first try, the power has gone and the laptop shutdown in the middle of downloading JDK7 using terminal as I was using the next terminal commands

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

when the power returned and I tried to install JDK7 again there was a problem with the lock but I fixed it using the following commands after restarting the machine

sudo apt-get install whatever

after that I tried installing again using the three commands above, the first was done with no errors and the second too,

but the third command downloaded the package successfully but an error appeared

Download done.
Removing outdated cached downloads...
sha256sum mismatch jdk-7u51-linux-i586.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:
 oracle-java7-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

I searched for solutions for this error and found some, tried the following instructions

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

tried again but the same "Oracle JDK7 is NOT installed" error appeared.

tried sudo apt-get -f install

salahuddin@salahuddin:~$ sudo apt-get -f install
[sudo] password for salahuddin: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  thunderbird-globalmenu
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 259 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up oracle-java7-installer (7u51-0~webupd8~1) ...
Downloading Oracle Java 7...
--2014-02-03 16:28:51--  http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-i586.tar.gz
Resolving download.oracle.com (download.oracle.com)... 41.128.128.35, 41.128.128.40
Connecting to download.oracle.com (download.oracle.com)|41.128.128.35|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-i586.tar.gz [following]
--2014-02-03 16:28:51--  https://edelivery.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-i586.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.48.230.140
Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.48.230.140|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-i586.tar.gz?AuthParam=1391437853_a122991b0aaf032ed8c2812472d1c92c [following]
--2014-02-03 16:28:53--  http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-i586.tar.gz?AuthParam=1391437853_a122991b0aaf032ed8c2812472d1c92c
Connecting to download.oracle.com (download.oracle.com)|41.128.128.35|:80... connected.
HTTP request sent, awaiting response... 416 Requested Range Not Satisfiable

    The file is already fully retrieved; nothing to do.

Download done.
Removing outdated cached downloads...
sha256sum mismatch jdk-7u51-linux-i586.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:
 oracle-java7-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

Don't know how to fix it

please help

thanks in advance

Salahuddin
  • 4,811

4 Answers4

19

Run the below commands on terminal,

sudo dpkg -P oracle-java7-installer
sudo apt-get -f install
Avinash Raj
  • 78,556
  • I was doing another installation while waiting for your answer, now I pressed Ctrl+Z to quit it, and when typed the first instruction you suggest it worked with no errors, the second one was endded with

    The following package was automatically installed and is no longer required: thunderbird-globalmenu Use 'apt-get autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 257 not upgraded. 5 not fully installed or removed. E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable) E: Unable to lock directory /var/cache/apt/archives/

    – Salahuddin Feb 03 '14 at 14:43
  • don't use ctrl+z,use ctrl+c to cancel the installation.Try this command to remove the lock sudo rm /var/cache/apt/archives/lock then run sudo apt-get autoremove – Avinash Raj Feb 03 '14 at 14:45
  • I tried Ctrl+C first but doesn't work, but Ctrl+Z worked – Salahuddin Feb 03 '14 at 14:49
  • I've removed the lock and tried the two instructions again

    salahuddin@salahuddin:~$ sudo dpkg -P oracle-java7-installer dpkg: warning: there's no installed package matching oracle-java7-installer salahuddin@salahuddin:~$ sudo apt-get -f install Reading package lists... Done Building dependency tree
    Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 257 not upgraded.

    Is it installed now?

    – Salahuddin Feb 03 '14 at 14:50
  • I think now your problem was solved.Did you run this command sudo dpkg -P oracle-java7-installer two times? – Avinash Raj Feb 03 '14 at 14:50
  • Yeah, the first time it worked but the second instruction didn't, the second time, the output I posted in the previous comment was generated.. would you edit your answer to explain what was the problem and how you solved it, thanks for your time – Salahuddin Feb 03 '14 at 14:53
  • did you want to know how do i did this?then see http://askubuntu.com/a/414365/202806 – Avinash Raj Feb 03 '14 at 14:55
  • bad news, When I typed "java -version" in the terminal to see if jdk is installed, the answer was "no "

    salahuddin@salahuddin:~$ java -version The program 'java' can be found in the following packages:

    • default-jre
    • gcj-4.6-jre-headless
    • openjdk-6-jre-headless
    • gcj-4.5-jre-headless
    • openjdk-7-jre-headless

    Try: sudo apt-get install

    so I'm trying "sudo apt-get install oracle-jdk7-installer" again

    – Salahuddin Feb 03 '14 at 14:56
  • now try to install java by running the first three commands which was on your question.That's all. – Avinash Raj Feb 03 '14 at 14:57
  • are the first and the second commands are mandatory, as I directly typed the third one and it's downloading the package now – Salahuddin Feb 03 '14 at 14:58
  • yes,try the 3rd one directly. – Avinash Raj Feb 03 '14 at 14:59
5

I have another potential workaround for this, but it requires manual intervention. The reason this has broken is because Oracle wants you to accept an OTN license. Here is workaround:

Go to Oracle Java7 JDK download site (I found it at Here). Agree to the OTN agreement, then find the file named "jdk-7u(whateverupdateislatest)-linux-x64.tar.gz"

sudo mv jdk-7u67-linux-x64.tar.gz /var/cache/oracle-jdk7-installer/



 sudo apt-get install oracle-java7-installer
Ashu_FalcoN
  • 2,118
Jim
  • 51
1

I think that your download is corrupted . you have to remove the corrupted package first by code :

sudo apt-get purge oracle-java7-installer

Clean your apt :

sudo apt clean

Remove and reimport the ropsitory :

sudo add-apt-repository --remove ppa:webupd8team/java
sudo apt-get update
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update

Install your package again :

sudo apt-get install oracle-java7-installer

Enjoy it bro ! if the problem hasn't solved try using VPN . Maybe there is a filtering between you and the oracle website

0

Check the file /var/cache/oracle-jdk7-installer/jdk-7u51-linux-*.tar.gz

If it is small (~5000 bytes) - then it contains text telling you to accept the OTN license.

If you can, switch to oracle-java8-installer

See http://tiemensfamily.com/TimOnCS/2014/03/15/oracle-adds-license-to-java7-installer-fails