Downloading Java JDK on Linux via wget is shown license page instead
Asked Answered
S

30

648

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?

Safety answered 22/4, 2012 at 14:3 Comment(0)
I
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.

Inga answered 9/6, 2012 at 9:21 Comment(32)
I assume this is the same process as shown in 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: oracle.com/technetwork/java/javase/downloads/index.html. This makes it a lot easier to update the link for your own commandline.Mirk
(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?Mirk
@Mirk yes we have to add "oraclelicense=accept-securebackup-cookie" with existing gpw_e24 cookie.Studer
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...Saccharate
@Mirk - 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...).Saccharate
@Irani: There's a stray - in the middle of your revised wget causing: wget: unable to resolve host address ‘-’. (Also, thanks for revising!)Tasse
@AlexDupuy, well, I've posted my answer. I didn't want it to be just a copy, so I went in to a little bit detail.Mirk
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.gzMirk
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.gzMirk
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.rpmDisinfection
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.Fulkerson
@Fulkerson you could also fetch the entire link from here with a little grep/cut/awk: oracle.com/technetwork/java/javase/downloads/…Mirk
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=.....)Gloucestershire
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.Saccharo
i tried the new 121 verson with url download.oracle.com/otn-pub/java/jdk/8u121-b13/… but it does not seem to work. any thought?Leaseback
@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: download.oracle.com/otn-pub/java/jdk/8u121-b13/…Fulkerson
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.rpmCestode
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.dmgCramfull
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;" "download.oracle.com/otn-pub/java/jdk/8u191-b12/…" -O /usr/local/src/jdk-8u191-linux-x64.rpmAlabaster
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. 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.Thine
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.Kenyettakenyon
I tried to use the same method to dowload latest 8 version but not working, download.oracle.com/otn/java/jdk/8u211-b12/… . Does anyone know any workaround?Leaseback
@NamNguyen yea you need to log in for those (accept, then download thru terminal with same ip). There's some Java versions in: adobe.com/support/coldfusion/downloads.html Idk what those are supposed to be, but checksums apparently match.Mirk
got the ERROR 404: Not Found with JDK 11, may be incorrect URL?Respondence
Can someone add also jdk-8u231-linux-x64.rpm since jdk8 has reached the end of public updates ?Schmaltz
This is the one worked for me: ` wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" download.oracle.com/otn-pub/java/jdk/8u131-b11/… `Typewrite
UPDATED FOR Oracle JDK 11 solution doesn't work anymoreArlana
If every option here fails for you, see my answer here: #44213954Tarsometatarsus
java 8 solution does not work anymore, it gives a 404 response statusAspergillosis
See this answer for JDK 17 onwards: https://mcmap.net/q/63849/-downloading-java-jdk-on-linux-via-wget-is-shown-license-page-insteadNephology
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;" "download.oracle.com/otn/java/jdk/8u202-b08/…"Phoenician
Updated for JDK 11 doesn't work anymore . Someone help.Seaport
M
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).

Mirk answered 17/3, 2014 at 22:8 Comment(28)
"preceding dash" should be "dash following either form of the option" but this is an excellent summarization.Saccharate
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.Mirk
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.gzExcaudate
Nope. .tar.gz doesn't existExcaudate
@Excaudate 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: oracle.com/technetwork/java/javase/downloads/…Mirk
no .tar.gz for windows JDK. :( the link you sent had for linux and solaris.Excaudate
@Excaudate .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.Mirk
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-8u77Trustful
Please don't recommend --no-check-certificate. That's just pure evil.Demeter
@Demeter it's explained pretty well in the answer. You can't download with Wget <1.13 without it.Mirk
@Mirk 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.Demeter
@Demeter 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.Mirk
112 released please wget cookie?Inexpressible
@Inexpressible I don't understand you?Mirk
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?Leaseback
@NamNguyen and what might the error and full commandline be in the "it does not seem to work" situation? Both work fine for me.Mirk
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?Asa
@Asa 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.Mirk
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 accountAsa
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.Gelasius
@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. ^^Mirk
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 ?Gelasius
@muni764 oracle.com/technetwork/java/javase/downloads/index.html > Java Archive (very bottom of page)Mirk
@Mirk 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?Gelasius
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/javaPestalozzi
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.debPestalozzi
11.0.2 was just released. What's the wget url like? How to find out the wget url in general? Thanks.Alvy
I tried to use the same method to dowload latest 8 version but not working, download.oracle.com/otn/java/jdk/8u211-b12/… . Does anyone know any workaround?Leaseback
T
39

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.

Tinstone answered 26/6, 2012 at 14:47 Comment(5)
Yes.. that works. Nice. I had my url like download.oracle.com/otn-pub/java/jdk/7u9-b05/…Pee
This is an interesting matter but does not answer the question. Clicking on FireFox is incompatible with "automate download".Treatment
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.Magically
excellent! the query param AuthParam has something to do with Oracle checking if the user has agreed to License or not.Fubsy
only solution working for me today. All the wget tricks above with accept cookie parameter didn't work.Vigue
S
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

Subserve answered 11/4, 2017 at 19:16 Comment(1)
This absolute helped me. To use the tar.gz I simply had to rename .rpm to .tar.gzIndiction
R
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.

Radburn answered 12/11, 2012 at 16:4 Comment(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".Treatment
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.Gambrell
V
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
Veratrine answered 6/8, 2018 at 20:25 Comment(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.Redevelop
R
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. : )

Rudin answered 25/6, 2013 at 6:55 Comment(0)
S
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
Safety answered 22/4, 2012 at 14:4 Comment(2)
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.Clemente
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.Safety
T
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
Touchhole answered 2/7, 2015 at 16:0 Comment(0)
M
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
Moses answered 13/6, 2012 at 13:30 Comment(2)
This works but I couldn't choose 6u48 because the part where you have 6u33-b03.Federation
On 2013-11-02, could not have this to work. Downloads a HTML registration page instead of the file.Treatment
L
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"
Lakesha answered 6/9, 2018 at 10:1 Comment(1)
I tried others command but nothing worked, but this one worked smoothly(run on 20/Sep/2019).Endways
C
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.

Crotch answered 11/4, 2018 at 16:29 Comment(0)
H
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.
Havildar answered 20/12, 2013 at 14:34 Comment(1)
I would strongly recommend against using --no-check-certificate when transmitting a password.Mcdonald
S
3

As already posted here: https://mcmap.net/q/65025/-how-to-install-java-sdk-on-centos

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.

Seda answered 18/1, 2017 at 12:59 Comment(1)
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.Crotch
H
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"
Hemolysis answered 24/9, 2017 at 15:33 Comment(0)
M
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!

Minnesinger answered 22/4, 2014 at 9:51 Comment(1)
so this is how it was implemented honoring the license. This is awesome :-)Wringer
K
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.

Kinch answered 25/4, 2017 at 20:0 Comment(0)
L
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

Lucero answered 9/2, 2014 at 0:32 Comment(0)
C
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

Cilla answered 19/5, 2015 at 11:55 Comment(0)
T
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.

Tolbooth answered 1/11, 2017 at 0:28 Comment(0)
J
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"

Jacklynjackman answered 18/1, 2018 at 13:35 Comment(1)
HTTP request sent, awaiting response... 403 Forbidden 2018-01-24 03:24:51 ERROR 403: Forbidden.Fordone
D
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.

Disquisition answered 7/2, 2018 at 13:45 Comment(0)
W
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
Winfordwinfred answered 13/6, 2018 at 8:26 Comment(0)
L
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

Landry answered 19/9, 2019 at 2:27 Comment(0)
R
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.

Reggiereggis answered 16/3, 2020 at 16:9 Comment(0)
D
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

Dacey answered 27/9, 2021 at 11:30 Comment(0)
D
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.

Durative answered 8/10, 2019 at 15:48 Comment(1)
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/Mccool
M
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.

Maximomaximum answered 29/3, 2020 at 17:39 Comment(0)
S
-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"
Sacken answered 6/12, 2013 at 13:13 Comment(0)
S
-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.

Spectacle answered 26/9, 2013 at 19:53 Comment(1)
Because people need this for automatic installation of java on servers with bash scripts.Telencephalon

© 2022 - 2024 — McMap. All rights reserved.