Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to install oracle jdk on CentOS machine using wget

Tags:

java

linux

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

[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.
like image 484
Passenger Avatar asked Dec 13 '22 22:12

Passenger


2 Answers

Updated September 17th, 2021

Oracle has decided to change JDK license. See the official blog post.

Among other things it now allows to download JDK from scripts without any need for storing specific hashes or accepting a license agreement. There is also a page "JDK 17 Script Friendly URLs" with usage examples for scripts. Here is an excerpt from that page:

For example, to retrieve the current JDK 17 update release for Linux x64 as a compressed (tar.gz) archive, you can use the wget command:

wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz

or with curl:

curl https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz

The checksum for the release can be found by adding .sha256 to the download URL:

https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz.sha256

These URLs will deliver the GA version of JDK 17 and its checksum until the release of the first Critical Patch Update. When 17.0.1 is released the above URLs will deliver 17.0.1 until the release of the 17.0.2 at which point the above URLs will deliver 17.0.2 and so on.

=== Previous version of the answer below ===

Oracle has updated links generation mechanism. 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:

For production use Oracle recommends downloading the latest JDK and JRE versions and allowing auto-update.

Only developers and Enterprise administrators should download these releases.

Downloading these releases requires an oracle.com account. 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.

See more at Oracle Java Archives page.

So you're stuck with two options now.

Option 1. Use the latest version (8u131 now) by a new direct link. The link is available at the Java SE Development Kit 8 downloads page after you accept the License agreement. 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:

yum install java-1.8.0-openjdk

See more about openjdk installation at OpenJDK: Download and install page.

like image 95
doz10us Avatar answered Dec 16 '22 13:12

doz10us


This kind of thing comes up repeatedly. The fundamental issue is that Oracle want you to read and agree to the license terms.

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. 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. (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 place1. Then change your automatic deployment code to fetch distros from that location.

  3. Switch to a 3rd-party provider of OpenJDK; e.g. a Linux package source, or one of providers who make OpenJDK binary distros available for free and unrestricted download.

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.


1 - 1) Check with your lawyers first. I think that the license allows this, but IANAL. 2) Do not deliberately or accidentally publish them, or you are liable to be on the wrong end of a copyright violation lawsuit!

like image 23
Stephen C Avatar answered Dec 16 '22 12:12

Stephen C