-
-
Save P7h/9741922 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. | |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### | |
## 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}" | |
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### |
Has anyone tried to do the same using windows bitsadmin
utility.
Is there an easy way for a script to get a list of the available jdk versions?
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?
It looks like they added some kind of hash to the path.
Anyone have 7u80 URL by chance?
@DrGirlfriend,
Now you need Oracle account to download old (archive) versions 😢
http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html
It seems Oracle added some kind of hash to the download url like "e9e7ea248e2c4826b92b3f075a80e441"
so links like
http://download.oracle.com/otn-pub/java/jdk/8u121-b13/jdk-8u121-linux-x64.tar.gz
won't work anymore.
👍
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.
You'll get a redirect to a url with an authparam parameter next (this is likely different every time)
👍
lol oracle broke something wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz
--2017-05-25 12:56:28-- http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 184.51.148.130, 184.51.148.122
Connecting to download.oracle.com (download.oracle.com)|184.51.148.130|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz [following]
--2017-05-25 12:56:28-- https://edelivery.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 104.90.82.236, 2600:141b:2000:1a1::2d3e, 2600:141b:2000:190::2d3e
Connecting to edelivery.oracle.com (edelivery.oracle.com)|104.90.82.236|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz?AuthParam=1495717108_a3711913bb9002a3938a746a49b4f4c4 [following]
--2017-05-25 12:56:28-- http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz?AuthParam=1495717108_a3711913bb9002a3938a746a49b4f4c4
Connecting to download.oracle.com (download.oracle.com)|184.51.148.130|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-05-25 12:56:30 ERROR 404: Not Found.
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
$ curl -i http://download.oracle.com/otn/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz
HTTP/1.1 302 Moved Temporarily
Server: AkamaiGHost
Content-Length: 0
Location: https://edelivery.oracle.com/akam/otn/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz
Date: Thu, 25 May 2017 14:52:10 GMT
Connection: keep-alive
@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™
@P7h I would recommend use sed to extract last part instead cut + 2 rev cmds
Line 22:
JDK_VERSION=echo $BASE_URL_8 | sed -r "s#.+/##"
Has anyone figured out how to generate the hash code?
@austinheap
Exactly. Have to switch to OpenJDK.
Has anyone figured out how to generate the hash code?
Still cannot figure out, anyone has a solution besides OpenJDK?
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.
The site is down :( does anyone have an alternative?
I wrote a shell script to automatically download Oracle SE JDK, support RHEL/Debian/SUSE and their variants distrobutions.
I created a version selection menu to support both Java 9 and Java 8 installation, add sha256 hash check to make source package is verified and authorized.
With parameter -h will list help info about the usage of the script.
Github url is https://github.com/MaxdSre/ShellScript/blob/master/assets/software/OracleSEJDK.sh.
@ghost
Your script worked like a charm!
However, maybe it would be better if /usr/lib/jvm/default-java
would link to the same location as JAVA_HOME
, namely /opt/OracleJDK
?
$ echo $JAVA_HOME
/opt/OracleJDK
$ sudo update-java-alternatives -l
awk: fatal: cannot open file `/usr/lib/jvm/*.jinfo' for reading (No such file or directory)
default-java /usr/lib/jvm/default-java
$ ls -l /usr/lib/jvm/ | grep java
lrwxrwxrwx 1 root root 24 Feb 25 2016 default-java -> java-1.8.0-openjdk-amd64
drwxr-xr-x 2 root root 4096 Aug 2 09:25 java-8-oracle
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?
Hi guys, Some one has a specific version link like 7u131 b12.
Hey guys, great resource! Does anyone has the download link for the latest jdk8 8u192 b12 release? Thanks!
Edited: 8u192 b12 link: http://download.oracle.com/otn-pub/java/jdk/8u192-b12/750e1c8617c5452694857ad95c3ee230/server-jre-8u192-linux-x64.tar.gz
It looks like as of 2019-04-16 you do now have to log in to an oracle account. Anyone finding a work around?
it doesnot work now. i tried below command, gives: 401 Authorization Required Username/Password Authentication Failed.
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn/java/jdk/8u211-b12/478a62b7d4e34b78b671c754eaaf38ab/jdk-8u211-linux-x64.tar.gz" -O jdk-8u211-linux-x64.tar.gz
any command to sign in oracle account- accept the license agreement - download the jdk tar.gz from cli?
the reason is becoz;
The Oracle JDK License has changed for releases starting April 16, 2019.
The new Oracle Technology Network License Agreement for Oracle Java SE is substantially different from prior Oracle JDK licenses. The new license permits certain uses, such as personal use and development use, at no cost -- but other uses authorized under prior Oracle JDK licenses may no longer be available. Please review the terms carefully before downloading and using this product. An FAQ is available here.
Oracle Java downloads now require logging in to an Oracle account to download Java updates, like the latest Oracle Java 8u211 / Java SE 8u212. Because of this I cannot update the PPA with the latest Java (and the old links were broken by Oracle).
For this reason, THIS PPA IS DISCONTINUED (unless I find some way around this limitation).
Oracle Java 8 is now stable. Below you'll find instructions on how to install it in Ubuntu / Linux Mint via a PPA repository. The PPA supports JDK8 for both 32bit and 64bit as well as ARM (ARM v6/v7 Hard Float ABI - there's no JDK 8 ARM Soft Float ABI archive available for download on Oracle's website).
please suggest anyone!
This is the official script you get from Oracle once an update has been found and selected from GUI
#!/bin/sh
#
# Generated 1/15/20 9:56 AM
# Start of user configurable variables
#
LANG=C
export LANG
# Trap to cleanup cookie file in case of unexpected exits.
trap 'rm -f $COOKIE_FILE; exit 1' 1 2 3 6
# SSO username
printf 'SSO UserName:'
read SSO_USERNAME
# Path to wget command
WGET=/usr/bin/wget
# Log directory and file
LOGDIR=.
LOGFILE=$LOGDIR/wgetlog-$(date +%m-%d-%y-%H:%M).log
# Print wget version info
echo "Wget version info:
------------------------------
$($WGET -V)
------------------------------" > "$LOGFILE" 2>&1
# Location of cookie file
COOKIE_FILE=$(mktemp -t wget_sh_XXXXXX) >> "$LOGFILE" 2>&1
if [ $? -ne 0 ] || [ -z "$COOKIE_FILE" ]
then
echo "Temporary cookie file creation failed. See $LOGFILE for more details." | tee -a "$LOGFILE"
exit 1
fi
echo "Created temporary cookie file $COOKIE_FILE" >> "$LOGFILE"
# Output directory and file
OUTPUT_DIR=.
#
# End of user configurable variable
#
# The following command to authenticate uses HTTPS. This will work only if the wget in the environment
# where this script will be executed was compiled with OpenSSL.
#
$WGET --secure-protocol=auto --save-cookies="$COOKIE_FILE" --keep-session-cookies --http-user "$SSO_USERNAME" --ask-password "https://updates.oracle.com/Orion/Services/download" -O /dev/null 2>> "$LOGFILE"
# Verify if authentication is successful
if [ $? -ne 0 ]
then
echo "Authentication failed with the given credentials." | tee -a "$LOGFILE"
echo "Please check logfile: $LOGFILE for more details."
else
echo "Authentication is successful. Proceeding with downloads..." >> "$LOGFILE"
$WGET --load-cookies="$COOKIE_FILE" --save-cookies="$COOKIE_FILE" --keep-session-cookies "https://updates.oracle.com/Orion/Services/download/p30425896_170251_Linux-x86-64.zip?aru=23313105&patch_file=p30425896_170251_Linux-x86-64.zip" -O "$OUTPUT_DIR/p30425896_170251_Linux-x86-64.zip" >> "$LOGFILE" 2>&1
$WGET --load-cookies="$COOKIE_FILE" "https://updates.oracle.com/Orion/Services/download/p30425890_180241_Linux-x86-64.zip?aru=23312695&patch_file=p30425890_180241_Linux-x86-64.zip" -O "$OUTPUT_DIR/p30425890_180241_Linux-x86-64.zip" >> "$LOGFILE" 2>&1
fi
# Cleanup
rm -f "$COOKIE_FILE"
echo "Removed temporary cookie file $COOKIE_FILE" >> "$LOGFILE"
But it's not useful since the links seem not to follow a naming convention, so you always need to find the proper link first manually. Hope someone finds a better solution, having to manually update this once a month is a pain
Line 25, add: "-linux-x64.rpm" "-linux-x86.rpm"