如何在 Debian Wheezy 上安装 Java 1.7_51?

如何在 Debian Wheezy 上安装 Java 1.7_51?

我正在尝试在 Debian Wheezy 上安装 Java 1.7_51:

apt-get install oracle-java7-installer=7u51-0~webupd8~1

从:http://www.webupd8.org/2012/06/how-to-install-oracle-java-7-in-debian.html

过去这是没问题的,现在我删除了旧的 1.7_45 并想要一个新的 1.7_51,但是不知何故安装失败了。

安装下载几个文件,其中之一是jdk-7u51-linux-x64.tar.gz,这是错误页面 HTML。请参阅下面的输出行:

HTTP 请求已发送,等待响应...200 OK 长度:5307 (5.2K)

[文本/html]保存至:`jdk-7u51-linux-x64。压缩文件

如何安装?

下面我展示的是命令输出的内容(http://pastebin.com/gPBCivvU):

$ sudo apt-get install oracle-java7-installer=7u51-0~webupd8~1
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  binfmt-support visualvm ttf-baekmuk ttf-unfonts ttf-unfonts-core ttf-kochi-gothic ttf-sazanami-gothic ttf-kochi-mincho ttf-sazanami-mincho ttf-arphic-uming firefox firefox-2 iceweasel mozilla-firefox iceape-browser mozilla-browser
  epiphany-gecko epiphany-webkit epiphany-browser galeon midbrowser moblin-web-browser xulrunner xulrunner-1.9 konqueror chromium-browser midori google-chrome
The following NEW packages will be installed:
  oracle-java7-installer
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/17.6 kB of archives.
After this operation, 110 kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package oracle-java7-installer.
(Reading database ... 41559 files and directories currently installed.)
Unpacking oracle-java7-installer (from .../oracle-java7-installer_7u51-0~webupd8~1_all.deb) ...
Processing triggers for shared-mime-info ...
Setting up oracle-java7-installer (7u51-0~webupd8~1) ...
Downloading Oracle Java 7...
--2014-03-15 18:02:52--  http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 84.53.175.152, 84.53.175.146
Connecting to download.oracle.com (download.oracle.com)|84.53.175.152|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz [following]
--2014-03-15 18:02:52--  https://edelivery.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 172.227.102.140
Connecting to edelivery.oracle.com (edelivery.oracle.com)|172.227.102.140|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/errors/download-fail-1505220.html [following]
--2014-03-15 18:02:53--  http://download.oracle.com/errors/download-fail-1505220.html
Connecting to download.oracle.com (download.oracle.com)|84.53.175.152|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5307 (5.2K) [text/html]
Saving to: `jdk-7u51-linux-x64.tar.gz'

     0K                                                      100%  387M=0s

2014-03-15 18:02:53 (387 MB/s) - `jdk-7u51-linux-x64.tar.gz' saved [5307/5307]

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

答案1

看起来下载失败了,因为它重定向到此页面:http://download.oracle.com/errors/download-fail-1505220.html

该页面显示 Oracle 认为您未接受许可证。因此我认为他们 (Oracle) 更改了下载程序中的某些内容,现在您使用的 webupd8 安装包无法直接访问该文件。

编辑:根据下面@dmourati 的下载方法,如果您有该文件,您可以将其放在“/var/cache/oracle-jdk7-installer/”中,如果该文件在那里可用,安装程序包将跳过下载并为您完成安装。

答案2

问题是下载的包与包中的校验和不匹配:

sha256sum mismatch jdk-7u51-linux-x64.tar.gz

您应该切换到其他镜像,运行apt-get update并尝试再次安装。如果问题仍然存在,则表示有东西正在更改您下载的文件。

Debian 的软件包下载镜像/存储库已设置/etc/apt/sources.list,您可以使用任何文本编辑器编辑此文件。

相关内容