Skip to content

Instantly share code, notes, and snippets.

@tjsoftworks
Forked from P7h/jdk_download.sh
Last active February 11, 2016 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjsoftworks/a0a954418f17249b847f to your computer and use it in GitHub Desktop.
Save tjsoftworks/a0a954418f17249b847f to your computer and use it in GitHub Desktop.
Script to download JDK / JRE / Java binaries from Oracle website from terminal / shell / command line / command prompt
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### 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.
### Another option:
###### curl -L -O -H "Cookie: oraclelicense=accept-securebackup-cookie" -k "http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.tar.gz"
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
## Latest JDK8 version released on 19th January, 2016: JDK8u71
BASE_URL_8=http://download.oracle.com/otn-pub/java/jdk/8u72-b15/jdk-8u72
## Earlier versions:
## 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
JDK_VERSION=${BASE_URL_8: -8}
declare -a PLATFORMS=("-macosx-x64.dmg","-windows-x64.exe" "-linux-x64.tar.gz" "-docs-all.zip" "-windows-i586.exe" "-linux-i586.tar.gz")
## Override the declared PLATFORMS to meet a specific purpose
declare -a PLATFORMS=("-macosx-x64.dmg")
for platform in "${PLATFORMS[@]}"
do
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}"
openssl sha256 "$JDK_VERSION$platform"
### compare to the the URL https://www.oracle.com/webfolder/s/digest/8u72checksum.html for the 8u72
done
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment