645

When I try to download Java from Oracle I instead end up downloading a page telling me that I need agree to the OTN license terms.

Sorry!

In order to download products from Oracle Technology Network you must agree to the OTN license terms.

Be sure that...

  • Your browser has "cookies" and JavaScript enabled.
  • You clicked on "Accept License" for the product you wish to download.
  • You attempt the download within 30 minutes of accepting the license.

How can I download and install Java?

random
  • 9,774
  • 10
  • 66
  • 83
thejartender
  • 9,339
  • 6
  • 34
  • 51

30 Answers30

1722

Works as of December 23rd, 2021 for JDK 17

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/java/17/archive/jdk-17.0.1_linux-x64_bin.rpm

Works as of July 27th, 2021 for JDK 16

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/16.0.2%2B7/d4a915d82b4c4fbb9bde534da945d746/jdk-16.0.2_linux-x64_bin.rpm

Works as of November 5th, 2020 for JDK 15

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/15.0.1+9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_linux-x64_bin.rpm

Works as of 07-11-2020 for JDK 14

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/14.0.1+7/664493ef4a6946b186ff29eb326336a2/jdk-14.0.1_linux-x64_bin.rpm -O ~/Downloads/jdk-14.0.1_linux-x64_bin.rpm

PS: Alf added this ( me ) :-) this, I couldn't figured out how to just commented at the end... Enjoy it.

UPDATED FOR Oracle JDK 11

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/11+28/55eed80b163941c8885ad9298e6d786a/jdk-11_linux-x64_bin.tar.gz

UPDATED FOR JDK 10.0.2

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_linux-x64_bin.tar.gz

UPDATED FOR JDK 10.0.1

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10.0.1+10/fb4372174a714e6b8c52526dc134031e/jdk-10.0.1_linux-x64_bin.tar.gz

UPDATED FOR JDK 9 it looks like you can download it now directly from java.net without sending a header

wget http://download.java.net/java/GA/jdk9/9/binaries/jdk-9+181_linux-x64_bin.tar.gz

UPDATED FOR JDK 8u191

TAR GZ:

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3a%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk8-downloads-2133151.html; oraclelicense=accept-securebackup-cookie;" "https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz"

RPM:

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3a%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk8-downloads-2133151.html; oraclelicense=accept-securebackup-cookie;" "https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.rpm"

UPDATED FOR JDK 8u131

RPM:

  wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm

TAR GZ:

 wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz

RPM using curl:

 curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm > jdk-8u112-linux-x64.rpm

In all cases above, subst 'i586' for 'x64' to download the 32-bit build.

  • -j -> junk cookies
  • -k -> ignore certificates
  • -L -> follow redirects
  • -H [arg] -> headers

curl can be used in place of wget.

UPDATE FOR JDK 7u79

TAR GZ:

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

RPM using curl:

curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm > jdk-7u79-linux-x64.rpm

Once again, make sure you specify the correct URL for the version you are downloading. You can find the URL here: Oracle JDK download site

ORIGINAL ANSWER FROM 9th June 2012

If you are looking to download the Oracle JDK from the command line using wget, there is a workaround. Run the wget command as follows:

wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz"

Be sure to replace the download link with the correct one for the version you are downloading.

willy919
  • 13
  • 2
Eric Kamara
  • 17,717
  • 1
  • 15
  • 18
  • I assume this is the same process as shown in http://askubuntu.com/a/170958, but it still only downloads what's actually an HTML file, which just tells me to accept the OTN license terms. Also, it'd be good to, if not for all the Java pages separately, then at least provide a link to the main page in the answer: http://www.oracle.com/technetwork/java/javase/downloads/index.html. This makes it a lot easier to update the link for your own commandline. – Det Mar 16 '14 at 13:04
  • 7
    _(Maybe this zillionth repost will finally do the trick.)_ A simple `--header "Cookie: oraclelicense=accept-securebackup-cookie"` (or `--header "Cookie: oraclelicense=[any-character(s)-but-a-single-space]"`) seems to work fine. Could you confirm this? – Det Mar 16 '14 at 16:50
  • @Det yes we have to add "oraclelicense=accept-securebackup-cookie" with existing gpw_e24 cookie. – arulraj.net Mar 17 '14 at 09:55
  • Thanks so much for the timely update on this. I added a bounty but SO won't let me award it to this updated answer for another 23 hours... – Alex Dupuy Mar 17 '14 at 10:46
  • 1
    @Det - your solution (--header "Cookie: oraclelicense=accept-securebackup-cookie"") actually works best (no need for --load-cookies or any other junk) - if you add this as a separate answer, I'll award that one the bounty (I guess this is why SO makes me wait a day...). – Alex Dupuy Mar 17 '14 at 12:04
  • @Irani: There's a stray `-` in the middle of your revised `wget` causing: `wget: unable to resolve host address ‘-’`. (Also, thanks for revising!) – Thanatos Mar 17 '14 at 17:28
  • @AlexDupuy, well, I've posted my [answer](http://stackoverflow.com/a/22466509/1821548). I didn't want it to be just a copy, so I went in to a little bit detail. – Det Mar 17 '14 at 22:10
  • 4
    Update for the fresh Java 8: `wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-x64.tar.gz`. The _--no-cookies_ is redundant and _--no-check-certificate_ is necessary only with _Wget_ 1.12 and older, which are missing SAN support (mainly RHEL/CentOS 6.x). The _cURL_ version is: `curl -L -C - -b "oraclelicense=accept-securebackup-cookie" -O http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-x64.tar.gz` – Det Mar 19 '14 at 01:11
  • 8u5. *Wget:* `wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u5-b13/jdk-8u5-linux-x64.tar.gz` - *cURL:* `curl -L -C - -b "oraclelicense=accept-securebackup-cookie" -O http://download.oracle.com/otn-pub/java/jdk/8u5-b13/jdk-8u5-linux-x64.tar.gz` – Det Apr 16 '14 at 08:25
  • 1
    This method also works for downloading the rpm. `wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.rpm` – Dave Mooney Apr 22 '14 at 20:36
  • The 7u65 download link is `http://download.oracle.com/otn-pub/java/jdk/7u65-b17/jdk-7u65-linux-x64.tar.gz`. Note the `b17`. Guess I'll need to add a loop to try downloading from all the different b-numbers. Damn you Oracle. – Banjer Jul 16 '14 at 13:41
  • @Banjer you could also fetch the entire link from here with a little `grep`/`cut`/`awk`: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html – Det Jul 16 '14 at 13:57
  • Add -O option to specify the output file name or the filename will be the desired jdk filename followed by some unwanted string (like ?AuthParam=.....) – Mingjiang Shi Oct 29 '14 at 08:14
  • I have to set the JAVA_HOME variable now, and I'm unsure of where java has installed itself. When I do a search in root I get a ton of results and I'm not sure what is what. – OKGimmeMoney Dec 23 '14 at 11:36
  • 3
    i tried the new 121 verson with url http://download.oracle.com/otn-pub/java/jdk/8u121-b13/jdk-8u121-linux-x64.tar.gz but it does not seem to work. any thought? – Nam Nguyen Jan 17 '17 at 23:10
  • 1
    @NamNguyen same here. Looks like Oracle added a long string of random chars to the URL now :(. So I guess we'll have to resort to web scraping to automate this. Current URL: http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz – Banjer Jan 18 '17 at 14:52
  • How to download previous releases and what would be the meaning of **b15** ? This is not working. `wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/6u45-b15/jdk-6u45-linux-x64.rpm` – Chaminda Bandara Apr 25 '17 at 09:31
  • 151 for osx (dmg) `wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-macosx-x64.dmg` – Nick Oct 19 '17 at 17:29
  • For latest java8 rpm : wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk8-downloads-2133151.html; oraclelicense=accept-securebackup-cookie;" "http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.rpm" -O /usr/local/src/jdk-8u191-linux-x64.rpm – Fredblabla Oct 17 '18 at 13:58
  • It will not work for version 10 because it has reached end of public support (September 2018). Oracle will not server the binaries any more to the public. https://www.oracle.com/technetwork/java/javase/eol-135779.html If you need it you should download it from another source but check the SHA hashes from Oracle. – hrvoj3e Oct 23 '18 at 07:29
  • 1
    `download.oracle.com/otn-pub` links for Java SE 8/11 no longer works, they were moved to `download.oracle.com/otn` a few days ago (2019-04-1?) which requires logging in. `javadl.oracle.com` links with `AutoDL` servlet still works. `javadl.oracle.com` links with `GetFile` servlet is best but never mentioned in any answer. – youfu Apr 19 '19 at 13:16
  • I tried to use the same method to dowload latest 8 version but not working, https://download.oracle.com/otn/java/jdk/8u211-b12/478a62b7d4e34b78b671c754eaaf38ab/jdk-8u211-linux-x64.tar.gz . Does anyone know any workaround? – Nam Nguyen Jun 05 '19 at 20:12
  • @NamNguyen yea you need to log in for those (accept, then download thru terminal with same ip). There's some Java versions in: https://www.adobe.com/support/coldfusion/downloads.html Idk what those are supposed to be, but checksums apparently match. – Det Jun 07 '19 at 14:23
  • 6
    got the ERROR 404: Not Found with JDK 11, may be incorrect URL? – Tien Dung Tran Dec 19 '19 at 03:19
  • Can someone add also jdk-8u231-linux-x64.rpm since jdk8 has reached the end of public updates ? – laertis Dec 31 '19 at 16:37
  • 1
    This is the one worked for me: ` wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm ` – Zubair Ahmed Jan 31 '20 at 23:19
  • 8
    UPDATED FOR Oracle JDK 11 solution doesn't work anymore – bomba Mar 03 '20 at 14:54
  • If every option here fails for you, see my answer here: https://stackoverflow.com/questions/44213454/not-able-to-install-oracle-jdk-on-centos-machine-using-wget/63609802#63609802 – Ojonugwa Jude Ochalifu Aug 27 '20 at 05:36
  • java 8 solution does not work anymore, it gives a 404 response status – 2xMax May 22 '21 at 06:23
  • See this answer for JDK 17 onwards: https://stackoverflow.com/a/69345833/840714 – Druckles Nov 02 '21 at 12:15
  • For Java8, below command works, tested in 2022: wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3a%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk8-download s-2133151.html; oraclelicense=accept-securebackup-cookie;" "https://download.oracle.com/otn/java/jdk/8u202-b08/1961070e4c9b4e26a04e7f5a083f551e/jdk-8u202-linux-x64.tar.gz" – swapnil shashank Mar 17 '22 at 00:31
  • Updated for JDK 11 doesn't work anymore . Someone help. – wizdemonizer Aug 13 '22 at 13:26
256

(Irani updated to my answer, but here's to clarify it all.)

Edit: Updated for Java 17.0.1, released in 19th October, 2021

Wget

wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz

See the downloads in oracle.com for more.

  • -c / --continue

Allows continuing an unfinished download.

  • --header "Cookie: oraclelicense=accept-securebackup-cookie"

Since 15th March 2014 this cookie is provided to the user after accepting the License Agreement and is necessary for accessing the Java packages in download.oracle.com. The previous (and first) implementation in 27th March 2012 made use of the cookie gpw_e24=http%3A%2F%2Fwww.oracle.com[...]. Both cases remain unannounced to the public.

The value doesn't have to be "accept-securebackup-cookie".

Not required

  • --no-cookies

The combination --no-cookies --header "Cookie: name=value" is mentioned as the "official" cookie support, but not strictly required here.

cURL

curl -L -C - -b "oraclelicense=accept-securebackup-cookie" -O https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
  • -L / --location

Required for cURL to redirect through all the mirrors.

  • -C / --continue-at -

See above. cURL requires the dash (-) in the end.

  • -b / --cookie "oraclelicense=accept-securebackup-cookie"

Same as -H / --header "Cookie: ...", but accepts files too.

  • -O

Required for cURL to save files (see [author's comparison][8] for more differences).

Det
  • 3,640
  • 5
  • 20
  • 27
  • 2
    "preceding dash" should be "dash following either form of the option" but this is an excellent summarization. – Alex Dupuy Mar 18 '14 at 08:27
  • 1
    Well, I changed it to "_cURL requires the dash (`-`) in the end._" That should be clear enough, taken how the other form of the `flag` is already shown in the command. – Det Mar 18 '14 at 15:27
  • Do you guys know how we could get the JDK 8u11 in .tar.gz format? oracle seems to just give it in .exe format. and there are some checksum-errors when using cabextract to extract the .exe and tarball it. JRE 8u11 seems to exist in .tar.gz – madCode Jul 16 '14 at 20:48
  • Nope. .tar.gz doesn't exist – madCode Jul 17 '14 at 04:47
  • @madCode I don't know where does this source come from, but they very _clearly_ exist, as the aforementioned commands both download the .tar.gz of the 64-bit JDK, and they are also very visible on the download page: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html – Det Jul 17 '14 at 17:17
  • no .tar.gz for windows JDK. :( the link you sent had for linux and solaris. – madCode Jul 23 '14 at 16:18
  • @madCode `.tar.gz` isn't really a Windows format. What you'd be looking for is something more familiar, like `.zip` or `.7z`. Unfortunately, as can be seen from the link, Oracle (just like Sun) only provides installers for Windows. – Det Jul 30 '14 at 10:53
  • `aria2c -j 10 -x 10 --check-certificate=false --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz` For jdk-8u77 – Sanchit Mar 30 '16 at 10:59
  • Please don't recommend `--no-check-certificate`. That's just pure evil. – Navin May 09 '16 at 03:42
  • @Navin it's explained pretty well in the answer. You can't download with Wget <1.13 without it. – Det May 14 '16 at 17:48
  • @Det Sure, but you should tell those users to update wget or use curl. If someone has a good reason for ignoring cert errors, they'll also know how to look in the man page. As it stands, a lot of unsuspecting users will copy that line in full. – Navin May 14 '16 at 22:40
  • @Navin if they are, I'm assuming they also don't care about reading manpages. That flag is the very first one explained below the commandline. – Det May 15 '16 at 10:07
  • 112 released please wget cookie? – elbarna Oct 29 '16 at 21:10
  • @elbarna I don't understand you? – Det Nov 25 '16 at 06:02
  • 1
    i tried the new 121 version with url download.oracle.com/otn-pub/java/jdk/8u121-b13/… but it does not seem to work. any thought? – Nam Nguyen Jan 17 '17 at 23:41
  • @NamNguyen and what might the error and full commandline be in the "it does not seem to work" situation? Both work fine for me. – Det Jan 19 '17 at 15:14
  • 1
    It seems doesn't work for old version. I can't download 8u121. Probably because of ```Downloading these releases requires an oracle.com account```. Any workaround? – ALex_hha May 24 '17 at 15:26
  • @ALex_hha not sure why you'd need an older version through the terminal, but you can Google the filename and there's a easily a few mirrors and FTP sites to choose from. – Det May 25 '17 at 17:45
  • 1
    We use docker, that's why we need to use specific version of java. Yes I can find the file on some ftp, but I've just mentioned that from now you can't download previous version from the site without their account – ALex_hha May 25 '17 at 19:59
  • Thank you for such blazing fast reaction, yesterday I was updating the script and then noticed you were updating it as well. But I was wondering myself, will that c2514751926b4512b076cc82f959763f hash or whatever is it broken quickly for the 9.0.4. Which probably will be anyway, as this whole SO proves that then thing keeps breaking. But to me it felt like session or some other mechanism which might expire rapidly. – Anton Krug Jan 18 '18 at 12:49
  • @muni764 no, that's their own hash they use for all releases of that version number (JRE/JDK 9.0.4 has the same one). If it changed, you wouldn't first of all get the same one as me. ^^ – Det Jan 19 '18 at 19:31
  • Did Oracle today deleted the Java9? Even from a web browser the links on the Download page lead to 404?! Is it their forced way to get people moved to a new version or it's just temporary quirk? Is it related to CVE-2017-5753, CVE-2017-5754, CVE-2017-5715 ? – Anton Krug Apr 18 '18 at 16:09
  • @muni764 http://www.oracle.com/technetwork/java/javase/downloads/index.html > Java Archive (very bottom of page) – Det Apr 18 '18 at 21:29
  • @Det The probably it was just quirk, because yesterday 9 was an official default download, yet the links it linked were 404. So I caught it a middle of transition? – Anton Krug Apr 19 '18 at 13:34
  • **tar.gz for 11.0.1+13-LTS**: `curl -fsS -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/11.0.1+13/90cf5d8f270a4347a95050320eef3fb7/jdk-11.0.1_linux-x64_bin.tar.gz | tar xzf - -C /opt/java` – Marslo Dec 27 '18 at 13:24
  • **ubuntu deb for 11.0.1+13-LTS**: `wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/11.0.1+13/90cf5d8f270a4347a95050320eef3fb7/jdk-11.0.1_linux-x64_bin.deb` – Marslo Dec 27 '18 at 13:24
  • 11.0.2 was just released. What's the wget url like? How to find out the wget url in general? Thanks. – Kok How Teh Jan 28 '19 at 03:39
  • I tried to use the same method to dowload latest 8 version but not working, https://download.oracle.com/otn/java/jdk/8u211-b12/478a62b7d4e34b78b671c754eaaf38ab/jdk-8u211-linux-x64.tar.gz . Does anyone know any workaround? – Nam Nguyen Jun 05 '19 at 20:13
38

Downloading Java from the command line has always been troublesome. What I have been doing reciently is to use FireFox (other browsers might work) to get a download started on my laptop, pause it (within the Downloads windows), use the "Copy Download Link" menu item of the context menu displayed for the downloading file. This URL can then be used on the Linux box to download the same file. I expect the URL has a short time to live. Ugly, but generally successful.

Andrew Gilmartin
  • 1,776
  • 12
  • 12
  • Yes.. that works. Nice. I had my url like http://download.oracle.com/otn-pub/java/jdk/7u9-b05/jdk-7u9-linux-x64.rpm?AuthParam=1353416364_849fe14f5fc48f297de56577ddfea856 – Mukus Nov 20 '12 at 12:57
  • 3
    This is an interesting matter but does not answer the question. Clicking on FireFox is incompatible with "automate download". – Stéphane Gourichon Nov 02 '13 at 08:35
  • 1
    Not as troublesome (translation: impossible) as in my browsers (plural) today. About 10 to 20% of the way in, Oracle's server would disconnect, leaving me with a truncated download. The CLI tool at least retries from where it left off, and eventually one of the runs will complete without time-out / rejection. – Roboprog Oct 06 '15 at 22:42
  • excellent! the query param `AuthParam` has something to do with Oracle checking if the user has agreed to License or not. – asgs May 24 '17 at 19:12
  • 1
    only solution working for me today. All the wget tricks above with accept cookie parameter didn't work. – Saad Benbouzid Jun 05 '20 at 10:30
23

Updated for JDK 8u171 RPM

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

Outdated links below

Updated for JDK 8u161 RPM

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm

Updated for JDK 8u152 RPM

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

Updated for JDK 8u144 RPM

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm

Updated for JDK 8u131 RPM

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

Updated for JDK 8u121 RPM

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.rpm

jdrews
  • 386
  • 2
  • 5
19

I know that Oracle made everything possible to make their Java Runtime and Java SDK as hard as possible.

Here are some guides for command line lovers.

For Debian like systems (tested on Debian squeeze and Ubuntu 12.x+)

su -
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
apt-get install --yes oracle-java7-installer
exit

Note: if you know a better or easier way add a comment, I will update the guide.

sorin
  • 161,544
  • 178
  • 535
  • 806
  • 2
    As of 2013-11-02, other methods are not easy to adjust with different versions. This method works whatever the current version is and can be automated/scripted/run unattended with apt-get options like "--yes". – Stéphane Gourichon Nov 02 '13 at 08:32
  • Tried this method with oracle-java8-installer with `--yes, --assume-yes, --force-yes` options but everytime installation wants me to accept license agreement with enter-key. – Drey May 29 '17 at 03:17
9

There is a good alternative for installing different JDK from the command line ... using https://sdkman.io/ there are plenty of vendedors

sdk install java 19.0.1-oracle
JPG
  • 750
  • 2
  • 8
  • 23
  • 1
    why `--no-check-certificate`? it works fine without that switch so in terms of security it should not be used, especially when it is obsolete. – tymik Apr 11 '19 at 14:12
7

latest tested,

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "https://edelivery.oracle.com/otn-pub/java/jdk/7u25-b15/jdk-7u25-linux-x64.tar.gz"

Be aware that certificate check is disabled if you care about absolute security. : )

Jason Xu
  • 2,903
  • 5
  • 31
  • 54
6

Oracle has put a prevention cookie on the download link to force you to agree to the terms even though the license agreement to use Java clearly states that merely by using Java you 'agree' to the license..

The method that Oracle wants is you to download it with an agreement. After that, this script cn be modified for your specific Linux

#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
#Modify these variables as needed...
tempWork=/tmp/work
locBin=/usr/local/bin
javaUsrLib=/usr/lib/jvm

sudo mkdir -p $javaUsrLib
mkdir -p $tempWork
cd $tempWork

#Extract the download
tar -zxvf $downloadDir/jdk*tar.gz

#Move it to where it can be found...

sudo mv -f $tempWork/jdk* $javaUsrLib/

sudo ln -f -s $javaUsrLib/jdk1/bin/* /usr/bin/

#Update this line to reflect versions of JDK...
export JAVA_HOME="$javaUsrLib/jdk1.7.0_03"
#Extract the download
tar -zxvf $tempWork/*

#Move it to where it can be found...

sudo mv -f $tempWork/jdk1* $javaUsrLib/

sudo ln -f -s $javaUsrLib/jdk1*/bin/* /usr/bin/
sudo rm -rf $tempWork
#Update this line to reflect newer versions of JDK...
export JAVA_HOME="$javaUsrLib/jdk1.7.0_03"

if ! grep "JAVA_HOME=$javaUsrLib/jdk1.7.0_03" /etc/environment
then
    echo "JAVA_HOME=$javaUsrLib/jdk1.7.0_03"| sudo tee -a /etc/environment
fi


exit 0
thejartender
  • 9,339
  • 6
  • 34
  • 51
  • 1
    This answer assumes that you are using Linux, and that you want to install it in a non-standard way / place, and a bunch of other things. A better answer would be "just follow the installation instructions on the download website" ... unless you are using Ubuntu, in which case there are other ways to do it. – Stephen C Jun 05 '12 at 09:41
  • 9
    And how's it odd that the answer assumes Linux when the question title includes Linux? The sceipt is not a one-size-fit-all given that Linux itself is not such. Given this is my own answer to my own question, I have tested it and it worked for me. – thejartender Feb 06 '13 at 16:41
6

For those needing JCE8 as well, you can download that also.

curl -L -C - -b "oraclelicense=accept-securebackup-cookie" -O http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip

Or

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip
Cole Stanfield
  • 2,437
  • 2
  • 19
  • 12
5

This works for the JDK 6, you just need to replace the download url with the latest version.

wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk6-downloads-1637591.html;" http://download.oracle.com/otn-pub/java/jdk/6u33-b03/jdk-6u33-linux-x64.bin
Hiro2k
  • 5,254
  • 4
  • 23
  • 28
5

this command can download jdk8 tgz package at now (2018-09-06), good luck !

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/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"
Kai
  • 679
  • 9
  • 11
4

Instead of using for every new Java version a new link or changing existing scripts, I was looking for a more generic way to automate the download of the required Java packages and later installation via yum localinstall ${JAVA_ENVIRONMENT}-${JAVA_VERSION}-linux-x64.rpm.

I've used a somehow trivial approach similar to manual/user action to find the package and to download it. I am also pretty sure that one will find a more elegant way to do it by using other tools like egrep, awk, etc.., so leave it as an example here:

#!/bin/bash

### Proxy settings
# If there is a company proxy 

PROXY="my.proxy.local:8080"
PROXY_TYPE="--proxy-ntlm" # or leave empty with ""
USER="user"
PASS='pass'

### Find out the links to JRE and JDK 
# To do so, got to the page http://www.oracle.com/technetwork/java/javase/downloads/

BASE_URL="technetwork/java/javase/downloads"

# Put the whole page into a single string/line

BASE_URL_OUTPUT="$(curl -s -k ${PROXY_TYPE} -x "http://${USER}:${PASS}@${PROXY}" -L0 http://www.oracle.com/${BASE_URL}/)"

# Define the environments to download 

JAVA_ENVIRONMENTS=("JRE" "JDK") # ! yet "SERVER-JRE"

for JAVA_ENVIRONMENT in "${JAVA_ENVIRONMENTS[@]}"
do

echo
echo "JAVA_ENVIRONMENT="$JAVA_ENVIRONMENT
echo

for (( JAVA_BASE_VERSION = 8; JAVA_BASE_VERSION <= 10; JAVA_BASE_VERSION += 2 ))  
do

echo "JAVA_BASE_VERSION="$JAVA_BASE_VERSION

### "Read the page"
# and follow the links for the package interested in 

DOWNLOAD_SITE="$(echo $BASE_URL_OUTPUT | grep -m 1 -io "${JAVA_ENVIRONMENT}${JAVA_BASE_VERSION}-downloads-[0-9]*.html" -- | tail -1)"
echo "DOWNLOAD_SITE="$DOWNLOAD_SITE

### Gather the necessary download links
# To do so, following the link to the download site
# reading and accept the license 
# 
# ... the greedy regular expression is to address the different syntax of the links
# and already prepared for OR .gz files 

DOWNLOAD_LINK_OUTPUT="$(curl -s -k ${PROXY_TYPE} -x "http://${USER}:${PASS}@${PROXY}" -L -j -H "Cookie: oraclelicense=accept-securebackup-cookie" http://www.oracle.com/${BASE_URL}/${DOWNLOAD_SITE} |  grep -io "filepath.*${JAVA_ENVIRONMENT}-[${JAVA_BASE_VERSION}].*linux[-_]x64[._].*\(rpm\)" -- | cut -d '"' -f 3 | tail -1)"

# and echo out the link

echo "DOWNLOAD_LINK_OUTPUT="$DOWNLOAD_LINK_OUTPUT

done

done

Since the download links are available now, one may proceed further with wget or curl.

U880D
  • 8,601
  • 6
  • 24
  • 40
3

All of the above seem to assume you know the URL for the latest Java RPM...

Oracle provide persistent links to the latest updates of each Java version as documented at https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=397248601136938&id=1414485.1 - though you need to create/log in to an Oracle Support account. *Otherwise you can only access the last "public" update of each Java version, e.g. 1.6_u45 (Mar 2013; Latest update is u65, Oct 2013)*

Once you know the persistent link, you should be able to resolve it to the real download; The following works for me, though I don't yet know if the "aru" reference changes.

ME=<myOracleID>
PW=<myOraclePW>
PATCH_FILE=p13079846_17000_Linux-x86-64.zip

echo "Get real URL from the persistent link"

wget -o getrealurl.out --no-cookies --no-check-certificate --user=$ME \
--password=$PW --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" \
https://updates.oracle.com/Orion/Services/download/$PATCH_FILE?aru=16884382&\
patch_file=$PATCH_FILE

wait    # wget appears to go into background, so "wait" waits 
        # until all background processes complete

REALURL=`grep "^--" getrealurl.out |tail -1 |sed -e 's/.*http/http/'`
wget -O $PATCH_FILE $REALURL
#These last steps must be done quickly, as the REALURL seems to have a short-lived 
#cookie on it and I've had no success with  --keep-session-cookies etc.
tfewster
  • 31
  • 2
3

As already posted here: https://stackoverflow.com/a/41718895/4370196

Update for JDK 8 Update 121

Since Oracle inserted some md5hash in their download links, one cannot automatically assemble a download link for command line.

So I tinkered some nasty bash command line to get the latest jdk download link, download it and directly install via rpm. For all who are interested:

wget -q http://www.oracle.com/technetwork/java/javase/downloads/index.html -O ./index.html && grep -Eoi ']+>' index.html | grep -Eoi '/technetwork/java/javase/downloads/jdk8-downloads-[0-9]+.html' | (head -n 1) | awk '{print "http://www.oracle.com"$1}' | xargs wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" -O index.html -q && grep -Eoi '"filepath":"[^"]+jdk-8u[0-9]+-linux-x64.rpm"' index.html | grep -Eoi 'http:[^"]+' | xargs wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" -q -O ./jdk8.rpm && sudo rpm -i ./jdk8.rpm

The bold part should be replaced by the package of your liking.

Community
  • 1
  • 1
Benjen
  • 134
  • 1
  • 8
  • Yes, it is not so easy anymore to assemble a link. I've used a similar approach in a bash script to get the latest JRE and JDK download links for version 8 and 9. It can be found [in this thread as answer](https://stackoverflow.com/a/49780226/6771046). – U880D Apr 11 '18 at 16:37
3

wget This Worked for me JDK8

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

I solve this (for Debian based Linux distros) by making packages using java-package a few times (for various architectures), then distributing them internally.

The big plus side is that this method always works; no matter how crazy Oracle's web pages become. Oracle can no longer break my build!

The downside is that it's a bit more work to set up initially.

  • Download the tar.gz files manually in a browser (thus "accepting" their terms)
  • Run make-jpkg jdk-7u51-linux-x64.tar.gz. This creates oracle-java8-jdk_8_amd64.deb
  • Distribute it within your organization

For distribution over the Internet, I suggest using a password protected apt repository or provide raw packages using symmetric encryption:

passphrase="Hard to crack string. Use /dev/urandom for inspiration."
gpg --batch --symmetric --force-mdc --passphrase-fd 0 \
   oracle-java8-jdk_8_amd64.deb <<< "$passphrase"

Of course providing (unencrypted) .deb packages on the internet is probably a violation of your license agreement with Oracle, which states:

... Oracle grants you a ... license ... to reproduce and use internally the Software complete and unmodified for the sole purpose of running Programs"

On the receiving end, if you have a password protected apt repo, all you need to do is apt-get install it. If you have raw packages, download, decrypt and dpkg -i them. Works like a charm!

mogsie
  • 4,021
  • 26
  • 26
2

The accepted answer was not working for me, as of 2017-04-25. However, the simple solution was using the -b flag instead of the --header option.

For example, to get jdk-1.8_131:

version='8u131'; wget -H -O jdk-$version-linux-x64.tar.gz --no-check-certificate --no-cookies -b "oraclelicense=a" http://download.oracle.com/otn-pub/java/jdk/$version-b11/jdk-$version-linux-x64.tar.gz

That will execute in the background, writing output to wget-log.

Scott Dudley
  • 3,256
  • 1
  • 18
  • 30
ILMostro_7
  • 1,422
  • 20
  • 28
1

Try

wget --no-cookies --header "Cookie: s_nr=1359635827494; s_cc=true; gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk6downloads-1902814.html; s_sq=%5B%5BB%5D%5D; gpv_p24=no%20value" http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64-rpm.bin --no-check-certificate -O ./jdk-6u45-linux-x64-rpm.bin

if you are like me trying to get Oracle JDK 6.

source: Oracle JVM download using curl/wget

ssgao
  • 5,151
  • 6
  • 36
  • 52
1

I've made a jdk-download script (specific for the tar.gz) for my gentoo boxes. Doesn't need to be updated like other similar scripts, trying to "brute-force" download the latest build for whatever version you want.

USAGE

jdk-download< <version> <platform> [<build>]

* <version> - Something like "8u40"
* <platform> - Usually i586 or x64
* <build> - The internal build number used by oracle, to avoid guessing and trying to download starting from 99 to 1 (build 0, really?!!)

Blog post

Source on bitbucket

Fabio Bonfante
  • 5,128
  • 1
  • 32
  • 37
1

oracle-java-download is a project on GitHub that allows you to create download links for JDK 8 and JDK 9 which you can use for further processing e.g in automated build or deployment processes.

It requires Linux, Docker and a JDK >= 8 to run.

aventurin
  • 2,056
  • 4
  • 26
  • 30
1

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/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm?AuthParam=1516282527_40effcfefd78d78bce12c0a4030a1b05"

1

Context

I recently faced the same problem and although the comments on this page and some others provided helpful hints - I thought it would be good to document the steps I took to fix the problem for folks who may be in need of further help.

System Details

I am following the PNDA set up on AWS by following the step by step pnda installation guide at:

https://github.com/pndaproject/pnda-guide/blob/develop/provisioning/aws/PREPARE.md

I am using ubuntu 14.04 [free tier eligible] on AWS cloud, and am running the code from 64 bit windows8.1 laptop. I am using PUTTY to connect to the server instance. I git cloned the pnda code from https://github.com/pndaproject/pnda to the ubuntu instance.

Important Note Please note that if you plan to use Ubuntu instance on AWS make sure it's 14.04 only. If you use version 16, it does not work. I learnt it the hard way!

Resolution Steps

As those who have gone as far as to have encountered the error being discussed here would know - the mirror creation file involves the following steps -

1) Run the script create_mirror.sh [ sudo su -s ./create_mirror.sh ] to run the full mirror creation process

2) This script in turn calls various other scripts - one of them being create_mirror_misc.sh; this script refers to pnda-static-file-dependencies.txt which has a list of files to be downloaded.

3) On the very first line of the pnda-static-file-dependencies.txt is a reference to download the jdk-8u131-linux-x64.tar.gz file from http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz oraclelicense=accept-securebackup-cookie; It is at this point that my script was failing with the message Failed to download http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz after 3 retries

4) I browsed to the page http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz and found the following error message displayed **In order to download products from Oracle Technology Network you must agree to the OTN license terms**

5) To resolve this problem I made the following change to the pnda-static-file-dependencies.txt; I added --no-check-certificate --no-cookies to bypass the license term agreement condition

6) So the revised code looks like - http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz --no-check-certificate --no-cookies oraclelicense=accept-securebackup-cookie

I hope this is helpful.

Stats_Lover
  • 396
  • 4
  • 11
1

you should try:

wget \
        --no-cookies \
        --header "Cookie: oraclelicense=accept-securebackup-cookie" \
        http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/jdk-8u172-linux-x64.tar.gz \
        -O java.tar.gz
Walterwhites
  • 1,287
  • 13
  • 9
1

download jdk 8u221

$ wget -c --content-disposition "https://javadl.oracle.com/webapps/download/AutoDL?BundleId=239835_230deb18db3e4014bb8e3e8324f81b43"
$ old=$(ls -hat | grep jre | head -n1)
$ mv $old $(echo $old | awk -F"?" '{print $1}')

my blog 044-wget下载jdk8u221

AnJia
  • 129
  • 7
1

Here's how to get the command yourself. This works for any version:

  1. Access packages page here: https://www.oracle.com/java/technologies/javase-jdk11-downloads.html
  2. Click the download link for your desired package
  3. Check the box indicating that you have "reviewed and accept..."
  4. Right-click & Copy the link address from the button
  5. Paste into a text editor and then copy everything AFTER 'nexturl=', beginning with 'https://'
  6. Update the download URL in this command and you should be good to go:

    wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn/java/jdk/11.0.6+8/90eb79fb590d45c8971362673c5ab495/jdk-11.0.6_linux-x64_bin.tar.gz

To further explain the wget, the --no-check-certificate should be clear enough, but the header content (for any call) is discoverable by using the Developer Tools Network Tab in your browser. The developer tools are powerful and are well worth the time to learn. Enjoy.

EvilKittenLord
  • 908
  • 4
  • 8
1

This problem will be solved from Oracle JDK 17 onwards -

https://www.oracle.com/java/technologies/jdk-script-friendly-urls/

The latest version of Oracle JDK 17 can be downloaded from a command line, or automatically in scripts and dockerfiles by using download URLs which will deliver the then current update release.

One can use -

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

format to get the latest 17 release

0

This happens because when you click the "Accept" button on the download page in your browser, the webpage saves a cookie that it uses to check your agreement before letting you download the file. The problem occurs when trying to download from the command line using wget and it's because there's no cookie information sent with the wget request for downloading the file so from the file server's perspective, you're a completely new user who hasn't accepted the license agreement.

One solution is to send cookie information using the --header option of the wget utility (as shown above in other answers). Ideally if some content is protected, you'd use the various session management options available with wget. For this particular problem however, it's solved (currently) by sending the Cookie header with the download request.

krishnakeshan
  • 1,242
  • 2
  • 14
  • 18
  • When you click "Accept" and grab the URL from that page, it directs you to `http://download.oracle.com/otn/java/...` instead of `http://download.oracle.com/otn-pub/java/...` Just change `/otn/` to `/otn-pub/` – T.CK Feb 05 '20 at 15:37
0

@eric answer did the trick for me, you need to accept terms in the command you are setting i.e

"Cookie: oraclelicense=accept-securebackup-cookie"

so your final command looks thus

wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz

You can decide to update the version by changing 8u131 to 8uXXX. so long it is available in the repo.

The Billionaire Guy
  • 3,382
  • 28
  • 31
-3
sudo wget --no-check-certificate --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.rpm"
nmeegama
  • 115
  • 1
  • 8
-4

Why not click to download from your browser then copy & paste the exact link where it was downloaded, for example:

wget http://download.oracle.com/otn-pub/java/jdk/7u40-b43/jdk-7u40-linux-x64.tar.gz?AuthParam=1380225131_dd70d2038c57a4729d8c0226684xxxx

You can find out the link by looking at the network tab of your browser after accepting terms in oracle and clicking to download. F12 in Chrome. Firebug in Firefox.

jacktrades
  • 7,224
  • 13
  • 56
  • 83