简体   繁体   English

无法使用 wget 在 CentOS 机器上安装 oracle jdk

[英]Not able to install oracle jdk on CentOS machine using wget

I want to install oracle java jdk 8 on CentOS I am not able to install java jdk because when I try to install java jdk using command我想在 CentOS 上安装 oracle java jdk 8 我无法安装 java jdk 因为当我尝试使用命令安装 java jdk

[root@ADARSH-PROD1 ~]# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u131-b27/jdk-8u131-linux-x64.rpm"

I receive output:我收到输出:

Connecting to edelivery.oracle.com 
(edelivery.oracle.com)|23.211.196.232|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u131-b27/jdk-8u131-    linux-x64.rpm?AuthParam=1495864027_230ebffd10615c26528e8d2496500338 [following]
--2017-05-27 11:15:07--  http://download.oracle.com/otn-pub/java/jdk/8u131-    b27/jdk-8u131-linux-x64.rpm?    AuthParam=1495864027_230ebffd10615c26528e8d2496500338
Connecting to download.oracle.com (download.oracle.com)|184.25.109.32|:80...     connected.
HTTP request sent, awaiting response... 404 Not Found
2017-05-27 11:15:09 ERROR 404: Not Found.

Oracle has updated links generation mechanism. Oracle 已更新链接生成机制。 It now includes some sequence, which seems to be persistent for a version but generated with a yet unknown mechanism.它现在包含一些序列,这些序列对于某个版本似乎是持久的,但是以未知的机制生成。 Also, to download any version except for latest you're now required to have Oracle account:此外,要下载除latest版本之外的任何版本,您现在需要拥有 Oracle 帐户:

For production use Oracle recommends downloading the latest JDK and JRE versions and allowing auto-update.对于生产用途,Oracle 建议下载最新的 JDK 和 JRE 版本并允许自动更新。

Only developers and Enterprise administrators should download these releases.只有开发人员和企业管理员才能下载这些版本。

Downloading these releases requires an oracle.com account.下载这些版本需要一个 oracle.com 帐户。 If you don't have an oracle.com account you can use the links on the top of this page to learn more about it and register for one for free.如果您没有 oracle.com 帐户,您可以使用本页顶部的链接了解更多信息并免费注册一个。

See more at Oracle Java Archives page.Oracle Java 档案页面查看更多信息。

So you're stuck with two options now.所以你现在有两个选择。

Option 1. Use the latest version ( 8u131 now) by a new direct link.选项 1.通过新的直接链接使用最新版本(现在是8u131 )。 The link is available at the Java SE Development Kit 8 downloads page after you accept the License agreement.在您接受许可协议后,可以在Java SE Development Kit 8 下载页面上找到该链接。 And your command will be:你的命令将是:

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm"

Option 2. Switch to openjdk package:选项 2.切换到openjdk包:

yum install java-1.8.0-openjdk

See more about openjdk installation at OpenJDK: Download and install page.OpenJDK 上查看有关 openjdk 安装的更多信息:下载和安装页面。

This kind of thing comes up repeatedly.这种事情反复出现。 The fundamental issue is that Oracle want you to read and agree to the license terms.根本问题是 Oracle 希望您阅读并同意许可条款。

It is a legal thing.这是一件合法的事情。 If you can implement a scheme where you can automate the downloading without a human being clicking the "I agree" button, there is a chance that some Judge may rule that the agreement terms do not apply to you.如果您可以实施一种无需人工单击“我同意”按钮即可自动下载的方案,则某些法官可能会裁定协议条款不适用于您。

Therefore, Oracle try to make it hard (or at least ... not simple) to automate downloads of the "free" versions of Java.因此,Oracle 试图使自动下载 Java 的“免费”版本变得困难(或至少……不简单)。 And every now and then they change the mechanisms.他们时不时地改变机制。

A couple of ways to deal with this would be:解决这个问题的几种方法是:

  1. Ask Oracle if they would give you access to a stable download site (presumably with password access control) if you payed for a license.询问 Oracle 如果您支付了许可费用,他们是否会让您访问稳定的下载站点(大概有密码访问控制)。 (I actually don't know if they do.) (我实际上不知道他们是否这样做。)

  2. Manually download the distro for each version of Java that you need and save them in a safe private place 1 .手动下载您需要的每个 Java 版本的发行版,并将它们保存在安全的私人位置1 Then change your automatic deployment code to fetch distros from that location.然后更改您的自动部署代码以从该位置获取发行版。

  3. Switch to a 3rd-party provider of OpenJDK;切换到 OpenJDK 的 3rd 方提供商; eg a Linux package source, or one of providers who make OpenJDK binary distros available for free and unrestricted download.例如,Linux 包源,或提供免费和无限制下载 OpenJDK 二进制发行版的提供商之一。

I'm aware that all of the above entail some effort.我知道以上所有这些都需要付出一些努力。 But then so does "faffing about" with scripted downloads from " http://download.oracle.com " each time there is an unheralded change.但是,每次出现未预知的变化时,从“ http://download.oracle.com ” 进行脚本下载也会“开玩笑”。


1 - 1) Check with your lawyers first. 1 - 1) 首先咨询您的律师。 I think that the license allows this, but IANAL.我认为许可证允许这样做,但 IANAL。 2) Do not deliberately or accidentally publish them, or you are liable to be on the wrong end of a copyright violation lawsuit! 2)请勿故意或不小心发布它们,否则您很可能会陷入侵犯版权的诉讼中!

For me, using wget directly on my remote Linux server failed every time no matter the script used.对我来说,无论使用什么脚本,每次直接在我的远程 Linux 服务器上使用wget都会失败。 It was either downloading the file as HTML or not downloading at all.它要么将文件下载为 HTML,要么根本不下载。

The best and surest way to do this install is to执行此安装的最佳和最可靠的方法是

  1. Forget wget and download the file directly to your system忘记wget并直接将文件下载到您的系统
  2. Use WinSCP or any other free SFTP or FTP client to transfer the file to your server使用 WinSCP 或任何其他免费的 SFTP 或 FTP 客户端将文件传输到您的服务器
  3. And then run yum localinstall <file-name.rpm> from the file location.然后从文件位置运行yum localinstall <file-name.rpm>

I had same issue as OP for jdk-8u131 and after checking the Option 1 command in the answer above against mine I noticed it was exactly the same.我遇到了与 jdk-8u131 的 OP 相同的问题,在检查了上面答案中的选项 1 命令后,我注意到它完全相同。 I cut paste that Option 1 answer and it worked though!我剪切粘贴了选项 1 的答案,但它起作用了! So, I then tried several times again with my original call (which is exactly the same) and it failed again several times with the same message and then on about the 5th or 6th go it worked...so I think, once you are using the latest URL, that it works fine with Option 1 but you might see the 404 error on more than one occasion - if so just wait and then retry.所以,然后我用我原来的电话(完全相同)再次尝试了几次,但它再次失败了几次,并显示相同的消息,然后在第 5 或 6 次去它工作......所以我想,一旦你使用最新的 URL,它与选项 1 一起工作正常,但您可能不止一次看到 404 错误 - 如果是这样,请等待然后重试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM