我正在尝试在 Ubuntu 12.04 上安装 Java 7。但每次我尝试时,它总是显示如下错误。这是当我尝试升级时出现的,即使 Java 7 尚未安装
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:~$
有人能告诉我如何解决这个问题吗?
答案1
好吧,看起来这是一个老问题,但还没有人回答,所以...我想迟做总比不做好。我也为此而烦恼。像你一样,大多数论坛只是告诉我使用 open-jdk。大多数人似乎不明白 open-jdk 和 jdk-7 并不是一对一的映射,开发人员依赖的许多工具根本无法与 open-jdk 一起使用。无论如何...
我找到了一个解决方案,可以帮我解决问题。希望它对你有用。
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
答案2
正如@Ahmad-sibai 所说
“最近,webupd8 团队停止分发 Oracle java 7 的安装程序。”
您可以做的是:
手动下载http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html如果您有 Oracle 支持帐户并且确实需要 Oracle JDK 6 或 7,则将它们放入缓存中。
将它们放在以下文件夹中:
/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)
使用 webupd8 安装程序再次安装
sudo apt-get install oracle-java7-installer
答案3
最近,webupd8 团队停止分发他们的 Oracle java 7 安装程序。
答案4
扩展 Ben 的回答,同时解决 Ahmad 的观点:将 Ben 的回答中的以下步骤替换为:
sudo apt-get install oracle-java7-installer
和:
sudo apt-get install oracle-java9-installer
如果这不起作用,只需运行以下命令安装默认版本:
sudo apt-get install default-jre
https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04