Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
wget command to install Oracle JAVA JDK from stupid oracle website for centos and ubuntu
# rpm
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"" \
-O jdk-7-linux-x64.rpm
# ubuntu
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"" \
-O jdk-7-linux-x64.tar.gz
# then
tar -xzvf jdk-7-linux-x64.tar.gz

n0ts commented Aug 17, 2014

Hi, this is very useful script.
I create a new script.
This script auto detect jdk download page from jdk download page.

skh- commented Oct 15, 2014

Thank you.

nodje commented Nov 5, 2014

so useful, thanks!

PS: I would just add -c or --continue for bad connections...

Thanks. A good alternative is beating one's head against a blunt object trying to accept Oracle's term via Lynx :/

Thank you, it works well for me.

donarus commented Feb 27, 2015

Thanks!! Very useful ... God bless you 😀

It works, thanks a lot!


Very useful! Thank you!

It is working. Thanks a lot!!

This works as intended on Ubuntu 14.04 for jdk1.8.0_65.
Thanks for this snippet

worked for me :) Thanks!

tmccoy commented Jan 19, 2016

Works great. Thank you!

Thanks, works for me :)

rdeva31 commented Apr 21, 2016

Is it just me or does it not work when wgetting the JRE? More specifically

Thanks 👍


I love you <3 - no homo




<3 <3 <3

cool thanks

ocarop commented Apr 25, 2017


Doesn't work anymore.

drlatt commented May 31, 2017

please who has a way to make this work, really frustrating...

lirao commented Jun 1, 2017

( TДT)It doesn't work anymore

Oracle has changed their schema for the path:

Notice the random giberish? Go to the respective download page, accept the terms and copy the desired URL, paste into the script.

--2017-06-08 00:00:52--
Resolving (,
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: [following]
--2017-06-08 00:00:53--
Resolving (, 2600:140e:6:39a::2d3e, 2600:140e:6:3b6::2d3e
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: [following]
--2017-06-08 00:00:54--
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-06-08 00:00:56 ERROR 404: Not Found.

I'm having this problem, and the proposed fixes from @scottvrosenthal didn't work. The idea from @jtgasper3 didn't work either since oracle doesn't associate a session key to the particular version of JDK i'm interested in (jdk-8u5-linux-x64.tar.gz); you can see confirm that here:

--2017-07-05 14:55:58--
Resolving (,

Connecting to (||:80... conn
HTTP request sent, awaiting response... 302 Moved Temporarily
64.tar.gz [following]
--2017-07-05 14:55:58--
Resolving (, 2600:1409
:a:193::2d3e, 2600:1409:a:183::2d3e
Connecting to (||:443... c
HTTP request sent, awaiting response... 302 Moved Temporarily
38E9FA4A31A81898CBB00D [following]
--2017-07-05 14:55:59--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 401 Authorization Required

Username/Password Authentication Failed.
ERROR: Service 'java' failed to build: The command '/bin/sh -c wget --no-cookies
 --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cook
ie"' re
turned a non-zero code: 6

mark-walle commented Jul 5, 2017

Followed Andrew Gilmartin's recommendation in this stack overflow thread to start the download in browser; pause the download; open your browser's downloads viewer (Ctrl+J in Chrome on Windows), and copy the download link location. That link will include a unique ?AuthParam= authentication hash in the URL, so it's a terrible work-around, but it allows you to WGET the file at least once (I expect the authentication expires eventually).


linukey commented Sep 30, 2017

very good, thanks

Perfect!!! Thank you

Thank you.... exactly what many of us need.

Are otn-pub url's still running today?? They released 8u151 today but seems to me that urls changed as well. Can anyone confirm, please?

leonraf commented Oct 18, 2017

I have the same problem...

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

wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" ""

lkamal commented Jan 22, 2018

Thanks a lot.

Updated for Java 9.0.4

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