Skip to content

Instantly share code, notes, and snippets.

@sheeplogh
Forked from P7h/jdk_download.sh
Last active August 29, 2015 14:22
Show Gist options
  • Save sheeplogh/c599c06bef5141da127e to your computer and use it in GitHub Desktop.
Save sheeplogh/c599c06bef5141da127e to your computer and use it in GitHub Desktop.
### 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.
# curl -O -J -L -H -C - "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
## Current latest JDK8 version: JDK8u45
BASE_URL=http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45
## Earlier versions:
## 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}
declare -a PLATFORMS=("-windows-x64.exe" "-windows-i586.exe" "-linux-x64.tar.gz" "-linux-i586.tar.gz" "-docs-all.zip")
for platform in "${PLATFORMS[@]}"
do
wget -c -O "$JDK_VERSION$platform" --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "${BASE_URL}${platform}"
done
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
## Current latest JDK7 version: JDK7u79
BASE_URL=http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79
## Previous versions
## v7u75 ==> http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75
## v7u71 ==> http://download.oracle.com/otn-pub/java/jdk/7u71-b14/jdk-7u71
JDK_VERSION=${BASE_URL: -8}
declare -a PLATFORMS=("-windows-x64.exe" "-windows-i586.exe" "-linux-x64.tar.gz" "-linux-i586.tar.gz" "-docs-all.zip")
for platform in "${PLATFORMS[@]}"
do
wget -c -O "$JDK_VERSION$platform" --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "${BASE_URL}${platform}"
done
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment