#!/bin/bash # ================================================================= # Shell script to download JDK and JRE binaries from Oracle # website using wget in terminal/command prompt. # ================================================================= # Forked from: https://gist.github.com/P7h/9741922 # ----------------------------------------------------------------- # # You can download all the binaries at once just by changing: # - VER_UPDATE # - BASE_URL # # 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 (use more enhanced 'array') # c. API Docs (use more enhanced 'array') # d. You can add more to the list of downloads are per your requirement. # # If you have you own scripts location and you want to download to another # instead of placing the scipt there, you will have to source it, for example: # $ cd ~/desired/location # $ chmod 700 ~/path/to/script.sh # $ . ~/path/to/script.sh # ----------------------------------------------------------------- # Latest JDK/JRE version (in this case 8u74 released in February 2016) VER_UPDATE=8u74 # URL for the lates updates BASE_URL=http://download.oracle.com/otn-pub/java/jdk/8u74-b02/ # JDK URL PART JDK=jdk-${VER_UPDATE} # JRE URL PART JRE=jre-${VER_UPDATE} # create subdir for version in cwd - this is the reason for sourcing # or running the script ONLY from within the target location either way # the subdirectory will be created in root location for the script mkdir ${VER_UPDATE} && cd ${VER_UPDATE} # declare 'array' of packages declare -a PACKAGES=(${JDK} ${JRE}) # declare 'array' of platform specific downloads declare -a PLATFORMS=("-windows-x64.exe" "-windows-i586.exe") # more enhanced 'array' of downloads (more files) # # declare -a PLATFORMS=("-windows-x64.exe" "-linux-x64.tar.gz" "-docs-all.zip" "-windows-i586.exe" "-linux-i586.tar.gz") # loop to get what you need for package in "${PACKAGES[@]}" do for platform in "${PLATFORMS[@]}" do wget -c --no-check-certificate --no-cookies \ --header "Cookie: oraclelicense=accept-securebackup-cookie" \ "${BASE_URL}${package}${platform}" done done