7

I'm trying to install Java 7 on my Ubuntu 12.04. But everytime I try, it always shows error like below. This is when I'm trying to upgrade even when the Java 7 is not installed

harits@harits-ubuntu:~$ sudo apt-get upgrade
[sudo] password for harits: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be upgraded:
  oracle-java7-installer
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/15.3 kB of archives.
After this operation, 3,072 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up oracle-java7-installer (7u3-0~eugenesan~precise4) ...
Downloading...
--2012-07-14 17:53:46--  http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-i586.tar.gz
Resolving download.oracle.com (download.oracle.com)... 111.94.254.10, 111.94.254.17
Connecting to download.oracle.com (download.oracle.com)|111.94.254.10|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-i586.tar.gz [following]
--2012-07-14 17:53:46--  https://edelivery.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-i586.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 184.51.118.174
Connecting to edelivery.oracle.com (edelivery.oracle.com)|184.51.118.174|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/errors/download-fail-1505220.html [following]
--2012-07-14 17:53:47--  http://download.oracle.com/errors/download-fail-1505220.html
Connecting to download.oracle.com (download.oracle.com)|111.94.254.10|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5307 (5.2K) [text/html]
Saving to: `./jdk-7u3-linux-i586.tar.gz'

     0K .....                                                 100% 95.1M=0s

2012-07-14 17:53:47 (95.1 MB/s) - `./jdk-7u3-linux-i586.tar.gz' saved [5307/5307]

Download done.
sha256sum mismatch jdk-7u3-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
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 oracle-java7-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
harits@harits-ubuntu:~$ 

Can somebody tell me how to fix this problem?

2
  • I dont understand are you trying to upgrade from 6 to 7 ? – Mark Kirby Jul 14 '12 at 11:47
  • At this point, I would just recommend using openJDK 7. sudo apt-get install openjdk-7-jre, and/or sudo apt-get install openjdk-7-jdk, if you plan on developing java apps. – Marco Scannadinari Jul 14 '12 at 15:55
10

Well looks like this is an old question but no one has answered it yet so... better late than never I guess. I've been ripping my hair out over this too. Like you most boards just tell me too use open-jdk. what most people don't seem to understand that open-jdk and jdk-7 are not one to one mappings of each other and many tools relied upon by developers simply don't work with open-jdk. ANYWAY...

I found a solution which solved the problem for me. Hopefully it will work for you.

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
1
3

As @Ahmad-sibai said

"Recently, webupd8 team stopped distributing their installer for Oracle java 7."

What you can do is to:

  1. manually download them from http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html and put them in cache if you have an Oracle Support account and you really need Oracle JDK 6 or 7.

  2. Place them in the following folder:

    /var/cache/oracle-jdk6-installer/ for JDK 6 (you'll need version 6u45)
    /var/cache/oracle-jdk7-installer/ for JDK 7 (you'll need version 7u80 for 32bit and 64bit or 7u60 for arm)
    
  3. Install again using the webupd8 installers

    sudo apt-get install oracle-java7-installer
    
1
  • 2
    It throws: Package oracle-java7-installer is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source – Junior Mayhé Apr 11 '18 at 16:33
2

Recently, webupd8 team stopped distributing their installer for Oracle java 7.

1

I tried Ben Glasser's answer, but it didn't work.

It tried the other answer here, https://stackoverflow.com/a/22955890/1198772, and it works.

We just need to download (manually) the latest jdk from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html, and replace the old jdk. Then try to install again.

-1

To expand on Ben's answer while also addressing Ahmad's point: Replace the following step in Bens answer:

sudo apt-get install oracle-java7-installer

With:

sudo apt-get install oracle-java9-installer

And if that doesn't work, just install the default version by running:

sudo apt-get install default-jre

https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.