Last active
October 6, 2021 09:58
-
-
Save hgomez/4697585 to your computer and use it in GitHub Desktop.
Oracle JVM download using curl/wget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 Your tip works like a charm. I'm able to download JDKs automatically without issue. 👍 :-D
@ivajloip How about downloading JDKs from archive page? I want to download JDK1.8_161
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
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