Skip to content

Instantly share code, notes, and snippets.

@hgomez
Last active October 6, 2021 09:58
Show Gist options
  • Save hgomez/4697585 to your computer and use it in GitHub Desktop.
Save hgomez/4697585 to your computer and use it in GitHub Desktop.
Oracle JVM download using curl/wget
# Downloading Oracle JVM without browser
Oracle requires you to accept its licence agreement before downloading its JVM.
It's a pain for those of us who do automation, native packages, Jenkins JVM deployment on slave...
I used Firefox and Firebug to sniff network exchanges.
## HTTP Request :
GET /otn-pub/java/jdk/6u39-b04/jdk-6u39-linux-i586.bin?AuthParam=1359814101_9685f919f8b3113a89574ec4570d47b2 HTTP/1.1
Host: download.oracle.com
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://www.oracle.com/technetwork/java/javase/downloads/jdk6downloads-1902814.html
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
Connection: keep-alive
# Using curl
curl -L --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/6u39-b04/jdk-6u39-linux-x64.bin -o jdk-6u39-linux-x64.bin
curl -L --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/6u41-b02/jdk-6u41-linux-x64.bin -o jdk-6u41-linux-x64.bin
# Using wget
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/6u39-b04/jdk-6u39-linux-x64.bin
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/6u41-b02/jdk-6u41-linux-x64.bin
You should be able to download Oracle JVMs from anywhere now.
Enjoy
Thanks to Kevin Decherf blog (http://blog.kdecherf.com/2012/04/12/oracle-i-download-your-jdk-by-eating-magic-cookies/), where I found to avoid injecting cookies but use a specific header
@ivajloip
Copy link

For me just

curl -L -b "oraclelicense=a" http://download.oracle.com/otn-pub/java/jdk/7u60-b19/jdk-7u60-linux-x64.tar.gz -O

was ok...

In order to download some other version, just substitude http://download.oracle.com/otn-pub/java/jdk/7u60-b19/jdk-7u60-linux-x64.tar.gz with the correct url - you can see it on the http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html page.

@skydrome
Copy link

Is there a way to download the embedded jre version this way also?
ex: http://download.oracle.com/otn/java/ejdk/8u33-b05/ejdk-8u33-fcs-linux-i586.tar.gz
none of the methods seems to work with packages not in the 'otn-pub' folder

@robert-blankenship
Copy link

Thanks a ton @ivajloip

@pythys
Copy link

pythys commented Mar 25, 2017

For anyone reading this, the suggestion from @ivajloip is the best and simplest solution. More specifically, the whole magic is in the flag -b "oraclelicense=a". Just pass that to any oracle JDK you want to download and that's it, no need for that big cookie string using --header or anything like that

@sdmcraft
Copy link

sdmcraft commented Jul 12, 2017

Thanks @ivajloip. An example would be
curl -L -b "oraclelicense=a" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz -O

Here's a script for downloading and setting up java:
https://gist.github.com/sdmcraft/2c5abbdeccf37e1642e5

@sirgatez
Copy link

sirgatez commented Feb 6, 2018

@ivajloip Your tip works like a charm. I'm able to download JDKs automatically without issue. 👍 :-D

@darshanlbangre
Copy link

@ivajloip How about downloading JDKs from archive page? I want to download JDK1.8_161

@ItMightBlow
Copy link

Unfortunatly this method is only possible for otn-pub downloads.

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