Skip to content

Instantly share code, notes, and snippets.

@sr75
Last active March 16, 2023 11:28
Show Gist options
  • Save sr75/11187116 to your computer and use it in GitHub Desktop.
Save sr75/11187116 to your computer and use it in GitHub Desktop.
wget command to install Oracle JAVA JDK from stupid oracle website for centos and ubuntu
http://d.stavrovski.net/blog/post/how-to-install-and-setup-oracle-java-jdk-in-centos-6
# rpm
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.rpm" \
-O jdk-7-linux-x64.rpm
# ubuntu
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.tar.gz" \
-O jdk-7-linux-x64.tar.gz
# then
tar -xzvf jdk-7-linux-x64.tar.gz
@AntonTumasov
Copy link

+1

@yogeshpathade
Copy link

Thanks. Looks like Oracle introduced the changes in the download.

wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/jdk-8u152-linux-x64.tar.gz"

@lkamal
Copy link

lkamal commented Jan 22, 2018

Thanks a lot.

Updated for Java 9.0.4

@gasperzupancic
Copy link

definitely a keeper! thanks

@BlackthornYugen
Copy link

It is dangerous to download and execute code downloaded over http without a checksum. Maybe consider doing something like this?:

JAVA_INSTALLER=jdk-9.0.4_linux-x64_bin.rpm
JAVA_INSTALLER_CHECKSUM=fd1da16430321827c7f4a0ece4e74d042a6632381d1d8e2c679f9de0ba0355cf
wget --no-check-certificate --continue -nv --header "Cookie: oraclelicense=accept-securebackup-cookie" \
    http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/${JAVA_INSTALLER} && \
    sha256sum ${JAVA_INSTALLER} | tee /dev/stderr | grep ${JAVA_INSTALLER_CHECKSUM} || exit 1 && \
    echo "CHECKSUM ${JAVA_INSTALLER_CHECKSUM} MATCHED"

@YiChengRepo
Copy link

YiChengRepo commented Apr 18, 2018

anyone got a working java 9.0.4 download script ? It seems I only got 404 from any script above, now and oracle has moved java 9 to the archive ?

Resolving download.oracle.com (download.oracle.com)... 23.56.184.127
Connecting to download.oracle.com (download.oracle.com)|23.56.184.127|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz [following]
--2018-04-18 13:12:03--  https://edelivery.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 184.87.188.169, 2a02:26f0:a1:2a0::2d3e, 2a02:26f0:a1:29d::2d3e
Connecting to edelivery.oracle.com (edelivery.oracle.com)|184.87.188.169|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz?AuthParam=1524053643_40a2027dba4ac5a5a7fb2208daefe657 [following]
--2018-04-18 13:12:03--  http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz?AuthParam=1524053643_40a2027dba4ac5a5a7fb2208daefe657
Connecting to download.oracle.com (download.oracle.com)|23.56.184.127|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-04-18 13:12:05 ERROR 404: Not Found.

@zz22394
Copy link

zz22394 commented Apr 27, 2018

Thanks.

Latest JDK8_171

wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.rpm"

@Nanduyana
Copy link

wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn/java/jdk/7u71-b14/jdk-7u71-linux-x64.rpm
--2018-05-25 13:28:03-- http://download.oracle.com/otn/java/jdk/7u71-b14/jdk-7u71-linux-x64.rpm
Resolving download.oracle.com... 23.45.132.164
Connecting to download.oracle.com|23.45.132.164|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/akam/otn/java/jdk/7u71-b14/jdk-7u71-linux-x64.rpm [following]
--2018-05-25 13:28:03-- https://edelivery.oracle.com/akam/otn/java/jdk/7u71-b14/jdk-7u71-linux-x64.rpm
Resolving edelivery.oracle.com... 23.77.174.7, 2600:1407:a000:39b::2d3e, 2600:1407:a000:382::2d3e
Connecting to edelivery.oracle.com|23.77.174.7|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://login.oracle.com:443/oam/server/osso_login?Site2pstoreToken=v1.2~EC062A1473FF0629A4~44892051D5617AB2FD5298C31948491256F9CA0F0682A29EF2E6D89ADD28FEBEBD23E852C2695FFE6BE4E2DDF4ABB39E09B7145942D6F01023A3F7483149CAA0B60A8F5CA4C75DF6C0AED4AAD4ABA36FB7E548EB48096033176C5EA9AC8A06A4F193894E87E470C36B1A3BD49852C5D957385B4BCE6C6B20C104231EFF9E8639BFFC09EFEA8F3B4937DE5B2A897C5430A40B1A88B123614FF112ABB303CC74A5F981A6FC7ECF2326AF2C6AD2668B251D9EA191DD774CE831F4B328EEC135629B75F05B5EEA0E4B4D231D6EC167A94E7817629717B9744E882C8DEBD477758C723FEDB830AD3FDC3DDA4824B80BE4A1E2 [following]
--2018-05-25 13:28:03-- https://login.oracle.com/oam/server/osso_login?Site2pstoreToken=v1.2~EC062A1473FF0629A4~44892051D5617AB2FD5298C31948491256F9CA0F0682A29EF2E6D89ADD28FEBEBD23E852C2695FFE6BE4E2DDF4ABB39E09B7145942D6F01023A3F7483149CAA0B60A8F5CA4C75DF6C0AED4AAD4ABA36FB7E548EB48096033176C5EA9AC8A06A4F193894E87E470C36B1A3BD49852C5D957385B4BCE6C6B20C104231EFF9E8639BFFC09EFEA8F3B4937DE5B2A897C5430A40B1A88B123614FF112ABB303CC74A5F981A6FC7ECF2326AF2C6AD2668B251D9EA191DD774CE831F4B328EEC135629B75F05B5EEA0E4B4D231D6EC167A94E7817629717B9744E882C8DEBD477758C723FEDB830AD3FDC3DDA4824B80BE4A1E2
Resolving login.oracle.com... 156.151.58.18
Connecting to login.oracle.com|156.151.58.18|:443... connected.
HTTP request sent, awaiting response... 401 Authorization Required
Authorization failed.

this is what i am getting, can you help me on this to download jdk1.7u71

@grayaii
Copy link

grayaii commented Jun 14, 2018

Nonething seems to work. The best solution is to manually download the file, save it to s3 or some secure location that you have access to, and then have your install scripts install it from there. Oracle seems to change its download link on a whim.

@alvaromuir
Copy link

Latest, 1.7.2
wget --no-cookies --no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie"
"http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/jdk-8u172-linux-x64.rpm"

@pmiklos
Copy link

pmiklos commented Jul 30, 2018

It doesn't seem to work anymore unfortunately. It gives 401 Authorization Required

@ajardan
Copy link

ajardan commented Jul 30, 2018

It just looks like Oracle is aggressively removing old versions of Java from now on. Only latest 8u181 is available for download.

Here is the command:

wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.rpm

@anilchejarla
Copy link

its very usefull thankyou soo much..

@shorif2000
Copy link

i tried this for http://www.oracle.com/technetwork/database/application-development/jdbc/downloads/jdbc-ucp-183-5013470.html but i still keep getting 401 Authorization Required

wget http://download.oracle.com/otn/utilities_drivers/jdbc/183/ojdbc8.jar --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"

@russelld58
Copy link

Thanks so much!!
still works for jre-8u192-linux-x64.tar.gz with edited script:
$ wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" \

"https://download.oracle.com/otn-pub/java/jdk/8u192-b12/750e1c8617c5452694857ad95c3ee230/jre-8u192-linux-x64.tar.gz"
-O jre-8-linux.tar.gz

@rehrumesh
Copy link

rehrumesh commented Jan 29, 2019

Doesn't work with JDK 11

@willzhang
Copy link

yes it is not work for jdk8u202

@ezst036
Copy link

ezst036 commented Apr 19, 2019

wget command requires username and password authentication now for this to work.

@jhaumont
Copy link

I confirm your point ezst036, I can't download it anymore from a curl or wget since the april 16th and the license update.
So now, I use a private S3

@manuelmsperanza
Copy link

Something goes wrong with https://login.oracle.com/sso/auth,
You get System error. Please re-try your action. If you continue to get this error, please contact the Administrator.

@harshblog150
Copy link

it doesnot work now. i tried below command, gives: 401 Authorization Required Username/Password Authentication Failed.

wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn/java/jdk/8u211-b12/478a62b7d4e34b78b671c754eaaf38ab/jdk-8u211-linux-x64.tar.gz" -O jdk-8u211-linux-x64.tar.gz

any command to sign in oracle account- accept the license agreement - download the jdk tar.gz from cli?
the reason is becoz;

The Oracle JDK License has changed for releases starting April 16, 2019.
The new Oracle Technology Network License Agreement for Oracle Java SE is substantially different from prior Oracle JDK licenses. The new license permits certain uses, such as personal use and development use, at no cost -- but other uses authorized under prior Oracle JDK licenses may no longer be available. Please review the terms carefully before downloading and using this product. An FAQ is available here.

Oracle Java downloads now require logging in to an Oracle account to download Java updates, like the latest Oracle Java 8u211 / Java SE 8u212. Because of this I cannot update the PPA with the latest Java (and the old links were broken by Oracle).

For this reason, THIS PPA IS DISCONTINUED (unless I find some way around this limitation).

Oracle Java 8 is now stable. Below you'll find instructions on how to install it in Ubuntu / Linux Mint via a PPA repository. The PPA supports JDK8 for both 32bit and 64bit as well as ARM (ARM v6/v7 Hard Float ABI - there's no JDK 8 ARM Soft Float ABI archive available for download on Oracle's website).
please help!

@mfeliciano
Copy link

This worked for me, for getting 8u131 version, which I needed: wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm

I got this from https://stackoverflow.com/questions/10268583/downloading-java-jdk-on-linux-via-wget-is-shown-license-page-instead, which lists commands for various versions.

@jenishngl
Copy link

tried the above and doesnt work anymore
wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz

We are getting the below error
"HTTP request sent, awaiting response... 401 Authorization Required"

@jmdsg
Copy link

jmdsg commented Aug 31, 2019

None of the above commands seems to work anymore.

I was able to download it with the following:

wget \
--continue \
--no-check-certificate \
-O jdk-11.0.4_linux-x64_bin.rpm \
--header "Cookie: oraclelicense=a" \
"https://download.oracle.com/otn/java/jdk/11.0.4+10/cf1bbcbf431a474eb9fc550051f4ee78/jdk-11.0.4_linux-x64_bin.rpm?AuthParam=1567225725_a1c0cdc68062ddd501584d78c7030671"

@robertlugg
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment