Skip to content

Instantly share code, notes, and snippets.

@hgomez
Created March 19, 2014 20:39
Show Gist options
  • Save hgomez/9650687 to your computer and use it in GitHub Desktop.
Save hgomez/9650687 to your computer and use it in GitHub Desktop.
wget to download Java 8
wget --continue --no-check-certificate -O jdk-8-linux-x64.tar.gz --header Cookie: oraclelicense=a http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-x64.tar.gz
@neoacevedo
Copy link

It won't work. Oracle will redirect to download-failed.html and this page is what actually you will download.

@Lampe2020
Copy link

Lampe2020 commented Mar 8, 2022

Easiest way to download every older version of Java for every OS:
go to https://www.oracle.com/java/technologies/downloads/archive/ scroll down a bit and select your desired version and click on its download link. Then accept the agreements, wait for the grey download button to become green, then click on it. On the login page that will most likely pop up at this point, log in with any account details from https://bugmenot.com/view/oracle.com
Enjoy your download!

@hexufeng
Copy link

hexufeng commented Jul 6, 2022

It won't work. Oracle will redirect to download-failed.html and this page is what actually you will download.

yes, it does't work now !

@sampipe
Copy link

sampipe commented Jul 28, 2022

Just extending this example for others so you can always just download the latest jdk8 in one script. This if you need a version other than x64 tar gz you will have to update it.

#!/bin/bash -x

# Find Latest version on Oracle
LATEST_PAGE=https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html

# Get file list
wget $LATEST_PAGE

LATEST_VERSION=`grep 'Java SE Development Kit 8' javase8u211-later-archive-downloads.html | head -1 | sed 's/.*\(8u.*\)<.*/\1/'`
LATEST_PATCH=`echo $LATEST_VERSION | sed 's/8u//g'`
LATEST_URL=`grep data-file= javase8u211-later-archive-downloads.html | grep -E "jdk-$LATEST_VERSION-linux-x64.tar.gz" | sed "s/.*data-file='\(.*\)'/\1/"`
rm javase8u211-later-archive-downloads.html

echo "Downloading....."

FILE=jdk-${LATEST_VERSION}-linux-x64.tar.gz
VERSION=`echo $LATEST_URL | awk -F\/ '{print $7}' | sed 's/8u//g'`
HASH=`echo $LATEST_URL | awk -F\/ '{print $8}'`
URL="https://javadl.oracle.com/webapps/download/GetFile/1.8.0_$VERSION/$HASH/linux-i586/$FILE"
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" $URL

@Lampe2020
Copy link

Not the official Oracle Java, but you can install openjdk-8-* on Linux to get a full Java 8.

@dnovak1
Copy link

dnovak1 commented Dec 14, 2022

Just extending this example for others so you can always just download the latest jdk8 in one script. This if you need a version other than x64 tar gz you will have to update it.

Thank you!

@sampipe
Copy link

sampipe commented Dec 14, 2022

I actually found I was downloading the LATEST -1 with my script above.. here is an update for the latest latest for x64 linux

LATEST_PAGE="https://www.oracle.com/java/technologies/downloads/#java8"
DOWNFILE=index.html

# Get file list
wget $LATEST_PAGE

LATEST_VERSION=`grep 'Java SE Development Kit 8' $DOWNFILE | head -1 | sed 's/.*\(8u.*\)<.*/\1/'`
LATEST_PATCH=`echo $LATEST_VERSION | sed 's/8u//g'`
LATEST_URL=`grep data-file= $DOWNFILE | grep -E "jdk-$LATEST_VERSION-linux-x64.tar.gz" | sed "s/.*data-file='\(.*\)'/\1/"`
rm $DOWNFILE

echo "Downloading....."

FILE=jdk-${LATEST_VERSION}-linux-x64.tar.gz
VERSION=`echo $LATEST_URL | awk -F\/ '{print $7}' | sed 's/8u//g'`
HASH=`echo $LATEST_URL | awk -F\/ '{print $8}'`
URL="https://javadl.oracle.com/webapps/download/GetFile/1.8.0_$VERSION/$HASH/linux-i586/$FILE"
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" $URL

@cimoreno
Copy link

@sampipe Your script worked wonderfully. I tried to tweak for jdk 11 but lack necessary skills to make it work right. Some of the code I can't wrap my head around. Have you by chance tried it for jdk 11?

@sampipe
Copy link

sampipe commented Jan 20, 2023

Sorry I don't have some at hand..it should be simple enough to work out but I'm off work for a week so couldn't have a look for prob near 10 days..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment