##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget. | |
### You can download all the binaries one-shot by just giving the BASE_URL. | |
### Script might be useful if you need Oracle JDK on Amazon EC2 env. | |
### Script is updated for every JDK release. | |
### Features:- | |
# 1. Resumes a broken / interrupted [previous] download, if any. | |
# 2. Renames the file to a proper name with including platform info. | |
# 3. Downloads the following from Oracle Website with one shell invocation. | |
# a. Windows 64 and 32 bit; | |
# b. Linux 64 and 32 bit; | |
# c. API Docs; | |
# d. You can add more to the list of downloads are per your requirement. | |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
## Latest JDK10 version is JDK10.0.2 released on 17th Jul, 2018. | |
BASE_URL_10=http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_ | |
declare -a PLATFORMS=("linux-x64_bin.tar.gz" "windows-x64_bin.exe" "doc-all.zip") | |
# declare -a PLATFORMS=("linux-x64_bin.rpm" "linux-x64_bin.tar.gz" "osx-x64_bin.dmg" "windows-x64_bin.exe" "solaris-sparcv9_bin.tar.gz" "doc-all.zip") | |
for platform in "${PLATFORMS[@]}" | |
do | |
# wget -c --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "${BASE_URL_9}${platform}" | |
curl -C - -LR#OH "Cookie: oraclelicense=accept-securebackup-cookie" -k "${BASE_URL_10}${platform}" | |
done | |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
##### Earlier versions: | |
## 10.0.2 => http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_ |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
##### curl variant: | |
## • -C OR --continue-at ==> continuation from the last download, if any. And -C - for auto-detection. | |
## • -L OR --location ==> follow requested page, if moved to a different location. | |
## • -O OR --remote-name ==> name the local file same as remote file name. | |
## • -# OR --progress-bar ==> displays transfer progress as a simple progress bar. [not to be used with -s] | |
## • -H OR --header ==> header/@file to be included in the request. | |
## • -R OR --remote-time ==> local file will get the remote file timestamp. | |
## • -s OR --silent ==> quiet mode. | |
## • -S OR --show-error ==> show errors, if any. | |
curl -C - -L -O -# -H "Cookie: oraclelicense=accept-securebackup-cookie" \ | |
"http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz" | |
curl -C - -L -O -R -s -S -H "Cookie: oraclelicense=accept-securebackup-cookie" \ | |
"http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz" | |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
##### wget variant: | |
## • -c OR --continue ==> resume getting a partially-downloaded file | |
## • -O OR --output-file=FILE ==> write documents to FILE | |
## • --no-check-certificate ==> don't validate the server's certificate | |
## • --no-cookies ==> don't use cookies | |
## • --header ==> insert STRING among the headers | |
wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" \ | |
"http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz" | |
wget -c -O "jdk-8u141-linux-x64.tar.gz" --no-check-certificate --no-cookies --header \ | |
"Cookie: oraclelicense=accept-securebackup-cookie" \ | |
"http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz" | |
## Other notes picked from https://gist.github.com/laertis/749e9832e8c904ccda2d207a9112e663 | |
## • --no-check-certificate | |
## Only required with wget 1.12 and earlier, which do not support | |
## Subject Alternative Name (SAN) certificates | |
## (mainly Red Hat Enterprise Linux 6.x and friends, such as CentOS). | |
## 1.13 was released in August 2011. | |
## • --no-cookies | |
## The combination --no-cookies --header "Cookie: name=value" is mentioned | |
## as the "official" cookie support, but not strictly required here. | |
## • --header "Cookie: oraclelicense=accept-securebackup-cookie" | |
## Since 15th March 2014 this cookie is provided to the user after accepting the License | |
## Agreementand 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. | |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget / curl. | |
### You can download all the binaries one-shot by just providing one BASE_URL. | |
### Script might be useful if you need Oracle JDK on Amazon EC2 env. | |
### Script is updated for every JDK release. | |
### Features:- | |
# 1. Resumes a broken / interrupted [previous] download, if any. | |
# 2. Renames the file to a proper name with including platform info. | |
# 3. Downloads the following from Oracle Website with one shell invocation. | |
# a. Windows 64 and 32 bit; | |
# b. Linux 64 and 32 bit; | |
# c. API Docs; | |
# d. You can add more to the list of downloads are per your requirement. | |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
## Latest JDK8 version is JDK8u171 released on 17th Jul, 2018. | |
BASE_URL_8=http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181 | |
JDK_VERSION=`echo $BASE_URL_8 | rev | cut -d "/" -f1 | rev` | |
declare -a PLATFORMS=("-linux-arm32-vfp-hflt.tar.gz" "-linux-arm64-vfp-hflt.tar.gz" "-linux-i586.rpm" "-linux-i586.tar.gz" "-linux-x64.rpm" "-linux-x64.tar.gz" "-macosx-x64.dmg" "-solaris-sparcv9.tar.Z" "-solaris-sparcv9.tar.gz" "-solaris-x64.tar.Z" "-solaris-x64.tar.gz" "-windows-i586.exe" "-windows-x64.exe" "-docs-all.zip") | |
# declare -a PLATFORMS=("-linux-x64.tar.gz" "-windows-x64.exe" "-docs-all.zip") | |
for platform in "${PLATFORMS[@]}" | |
do | |
### wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" "${BASE_URL_8}${platform}" | |
curl -C - -LR#OH "Cookie: oraclelicense=accept-securebackup-cookie" "${BASE_URL_8}${platform}" | |
done |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget. | |
### You can download all the binaries one-shot by just giving the BASE_URL. | |
### Script might be useful if you need Oracle JDK on Amazon EC2 env. | |
### Script is updated for every JDK release. | |
### Features:- | |
# 1. Resumes a broken / interrupted [previous] download, if any. | |
# 2. Renames the file to a proper name with including platform info. | |
# 3. Downloads the following from Oracle Website with one shell invocation. | |
# a. Windows 64 and 32 bit; | |
# b. Linux 64 and 32 bit; | |
# c. API Docs; | |
# d. You can add more to the list of downloads are per your requirement. | |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
## Latest JDK9 version is JDK9.0.1 released on 16th Jan, 2018. | |
BASE_URL_9=http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_ | |
declare -a PLATFORMS=("linux-x64_bin.tar.gz" "windows-x64_bin.exe" "doc-all.zip") | |
# declare -a PLATFORMS=("linux-x64_bin.rpm" "linux-x64_bin.tar.gz" "osx-x64_bin.dmg" "windows-x64_bin.exe" "solaris-sparcv9_bin.tar.gz" "doc-all.zip") | |
for platform in "${PLATFORMS[@]}" | |
do | |
# wget -c --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "${BASE_URL_9}${platform}" | |
curl -C - -LR#OH "Cookie: oraclelicense=accept-securebackup-cookie" -k "${BASE_URL_9}${platform}" | |
done | |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
##### Earlier JDK9 versions: | |
## 9u1 => http://download.oracle.com/otn-pub/java/jdk/9.0.1+11/jdk-9.0.1_ | |
## 9u0 => http://download.oracle.com/otn-pub/java/jdk/9+181/jdk-9_ |
##### Earlier JDK8 versions: | |
## 8u171 => http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171 | |
## 8u161 => http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161 | |
## 8u151 => http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151 | |
## 8u144 => http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144 | |
## 8u141 => http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141 | |
## 8u131 => http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131 | |
## 8u121 => http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121 | |
## 8u111 => http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111 | |
## 8u101 => http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101 | |
## v8u91 => http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91 | |
## v8u77 => http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77 | |
## v8u73 => http://download.oracle.com/otn-pub/java/jdk/8u73-b02/jdk-8u73 | |
## v8u71 => http://download.oracle.com/otn-pub/java/jdk/8u71-b15/jdk-8u71 | |
## v8u65 => http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65 | |
## v8u60 => http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60 | |
## v8u51 => http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51 | |
## v8u45 => http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45 | |
## v8u40 => http://download.oracle.com/otn-pub/java/jdk/8u40-b25/jdk-8u40 | |
## v8u31 => http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31 | |
## v8u25 => http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25 | |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
##### Previous iteration commands [just for reference]: | |
wget -c -O "$JDK_VERSION$platform" --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" \ | |
"${BASE_URL_8}${platform}" | |
curl -L -O -H "Cookie: oraclelicense=accept-securebackup-cookie" -k "${BASE_URL_8}${platform}" | |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### |
This comment has been minimized.
This comment has been minimized.
Thanks @opendevnet. That |
This comment has been minimized.
This comment has been minimized.
inetquestion
commented
Mar 19, 2015
I'm new to GIT, sorry if this is breaking any kind of etiquette... Combined the two codes above into one script. Its smaller, but may be more difficult to read for some. It does indeed download the latest 1.7 & 1.8 JDK's as configured. Two questions:
-Inet Begin KSH Script!/bin/kshConfigurationMethod=curl Mainfor base in ${BASE[@]}; do |
This comment has been minimized.
This comment has been minimized.
@inetquestion, |
This comment has been minimized.
This comment has been minimized.
shlomoa
commented
Apr 18, 2015
Guys, note the difference in the base URL: |
This comment has been minimized.
This comment has been minimized.
The current script should work fine. I tested it just now.
|
This comment has been minimized.
This comment has been minimized.
dedetok
commented
Jun 5, 2015
this one work to download JDK 8 Update 45 wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz 100%[======================================>] 173,271,626 2.12M/s in 74s 2015-06-06 01:21:16 (2.23 MB/s) - `jdk-8u45-linux-x64.tar.gz.1' saved [173271626/173271626] |
This comment has been minimized.
This comment has been minimized.
rodgermoore
commented
Aug 7, 2015
EPIC |
This comment has been minimized.
This comment has been minimized.
TomNussbaumer
commented
Sep 10, 2015
Really nice script. There is just one minor bug, because you cannot garantee that update version numbers stay below 99. ## this will break for update numbers > 99
JDK_VERSION=${BASE_URL_8: -8}
## FIX: extract last part of url (only valid if using bash)
JDK_VERSION=${BASE_URL_8##*/} |
This comment has been minimized.
This comment has been minimized.
MatthiasLohr
commented
Nov 12, 2015
BaseURL for Java 7u60 (if somebody needs that):
|
This comment has been minimized.
This comment has been minimized.
Michaelangel007
commented
Jan 10, 2016
Example for OSX: curl -L -O -H "Cookie: oraclelicense=accept-securebackup-cookie" -k "https://edelivery.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-macosx-x64.dmg" |
This comment has been minimized.
This comment has been minimized.
lasclocker
commented
Apr 6, 2016
Thx! solved my problems. |
This comment has been minimized.
This comment has been minimized.
tibers
commented
Apr 21, 2016
Line 25, add: "-linux-x64.rpm" "-linux-x86.rpm" |
This comment has been minimized.
This comment has been minimized.
antonevane
commented
May 11, 2016
•
Has anyone tried to do the same using windows |
This comment has been minimized.
This comment has been minimized.
SKelem
commented
Nov 10, 2016
Is there an easy way for a script to get a list of the available jdk versions? |
This comment has been minimized.
This comment has been minimized.
gdbtek
commented
Jan 17, 2017
JDK 121 has released but this url does not seem to work http://download.oracle.com/otn-pub/java/jdk/8u121-b13/jdk-8u121-linux-x64.tar.gz. Anyone has any thought? |
This comment has been minimized.
This comment has been minimized.
CODYQX4
commented
Jan 18, 2017
It looks like they added some kind of hash to the path. |
This comment has been minimized.
This comment has been minimized.
DrGirlfriend
commented
Jan 27, 2017
Anyone have 7u80 URL by chance? |
This comment has been minimized.
This comment has been minimized.
nerro
commented
Feb 11, 2017
@DrGirlfriend, |
This comment has been minimized.
This comment has been minimized.
dukas
commented
Feb 24, 2017
It seems Oracle added some kind of hash to the download url like "e9e7ea248e2c4826b92b3f075a80e441" |
This comment has been minimized.
This comment has been minimized.
jlrigau
commented
Mar 10, 2017
|
This comment has been minimized.
This comment has been minimized.
mgallig
commented
Apr 13, 2017
•
You can get the real download URL's from the javascript array in the download page. That said, there seems to be something else going on as well now. I just regex match the full page source with e.g. "(http://download.*windows-i586.exe)" Sending the correct cookies, you will then get a redirect 302 to a location with an AuthParam hash Your URL must start with edelivery.oracle.com not the download.oracle.com as they've supplied, but is otherwise identical. |
This comment has been minimized.
This comment has been minimized.
marcuslang
commented
May 24, 2017
|
This comment has been minimized.
This comment has been minimized.
knope
commented
May 25, 2017
lol oracle broke something
|
This comment has been minimized.
This comment has been minimized.
Alexhha
commented
May 25, 2017
Yes, now you have to get account on oracle.com to be able to download old version. http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html Downloading these releases requires an oracle.com account
|
This comment has been minimized.
This comment has been minimized.
austinheap
commented
May 25, 2017
@Alexhha having to create an account to download old software and breaking every Ansible java playbook in use is a new Feature You'll Love From Oracle™ |
This comment has been minimized.
This comment has been minimized.
gonzalesraul
commented
May 26, 2017
•
@P7h I would recommend use sed to extract last part instead cut + 2 rev cmds Line 22: |
This comment has been minimized.
This comment has been minimized.
n0rbs
commented
May 29, 2017
Has anyone figured out how to generate the hash code? |
This comment has been minimized.
This comment has been minimized.
Alexhha
commented
May 29, 2017
@austinheap |
This comment has been minimized.
This comment has been minimized.
kkadir
commented
Jun 6, 2017
•
Still cannot figure out, anyone has a solution besides OpenJDK? |
This comment has been minimized.
This comment has been minimized.
nerro
commented
Jun 6, 2017
you can still download latest Java version without OTN account. And the link (with generated hash code) you can get with help of this site https://lv.binarybabel.org/catalog/java/jdk8. |
This comment has been minimized.
This comment has been minimized.
krummler
commented
Jul 6, 2017
The site is down :( does anyone have an alternative? |
This comment has been minimized.
This comment has been minimized.
ghost
commented
Sep 22, 2017
•
I wrote a shell script to automatically download Oracle SE JDK, support RHEL/Debian/SUSE and their variants distrobutions. |
This comment has been minimized.
This comment has been minimized.
taurus227
commented
Oct 20, 2017
@ghost
|
This comment has been minimized.
This comment has been minimized.
jonmaloney
commented
Jan 19, 2018
It seems like Oracle has changed the way that java can be downloaded. You now need to have an oracle account and login before you can download some of the archived java versions. Does anyone have a bash script that is able to login as well as download these files? |
This comment has been minimized.
This comment has been minimized.
ShinJR
commented
Jul 17, 2018
Hi guys, Some one has a specific version link like 7u131 b12. |
This comment has been minimized.
This comment has been minimized.
thorsten-plause
commented
Oct 25, 2018
•
Hey guys, great resource! Does anyone has the download link for the latest jdk8 8u192 b12 release? Thanks! |
This comment has been minimized.
opendevnet commentedSep 18, 2014
For reference, here is a
curl
equivalent: