When I try to download Java from Oracle I instead end up downloading a page telling me that I need agree to the OTN license terms.
Sorry!
In order to download products from Oracle Technology Network you must agree to the OTN license terms.
Be sure that...
- Your browser has "cookies" and JavaScript enabled.
- You clicked on "Accept License" for the product you wish to download.
- You attempt the download within 30 minutes of accepting the license.
How can I download and install Java?
(Irani updated to my answer, but here's to clarify it all.)
Edit: Updated for Java 11.0.1, released in 16th October, 2018
Wget
JRE 8u191 (no cookie flags): http://javadl.oracle.com/webapps/download/AutoDL?BundleId=235717_2787e4a523244c269598db4e85c51e0c
See the downloads in oracle.com and java.com for more.
-c / --continue
Allows continuing an unfinished download.
--header "Cookie: oraclelicense=accept-securebackup-cookie"
Since 15th March 2014 this cookie is provided to the user after accepting the License Agreement and 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.The value doesn't have to be "
accept-securebackup-cookie
".Required for Wget<1.13
--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.
To see the current version, use:
wget --version | head -1
Not required
--no-cookies
The combination
--no-cookies --header "Cookie: name=value"
is mentioned as the "official" cookie support, but not strictly required here.cURL
-L / --location
Required for cURL to redirect through all the mirrors.
-C / --continue-at -
See above. cURL requires the dash (
-
) in the end.-b / --cookie "oraclelicense=accept-securebackup-cookie"
Same as
-H / --header "Cookie: ..."
, but accepts files too.-O
Required for cURL to save files (see author's comparison for more differences).
oracle-java-download is a project on GitHub that allows you to create download links for JDK 8 and JDK 9 which you can use for further processing e.g in automated build or deployment processes.
It requires Linux, Docker and a JDK >= 8 to run.
As already posted here: https://stackoverflow.com/a/41718895/4370196
Update for JDK 8 Update 121
Since Oracle inserted some md5hash in their download links, one cannot automatically assemble a download link for command line.
So I tinkered some nasty bash command line to get the latest jdk download link, download it and directly install via rpm. For all who are interested:
The bold part should be replaced by the package of your liking.
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm?AuthParam=1516282527_40effcfefd78d78bce12c0a4030a1b05"
UPDATED FOR Oracle JDK 11
UPDATED FOR JDK 10.0.2
UPDATED FOR JDK 10.0.1
UPDATED FOR JDK 9 it looks like you can download it now directly from java.net without sending a header
UPDATED FOR JDK 8u191
TAR GZ:
RPM:
UPDATED FOR JDK 8u131
RPM:
TAR GZ:
RPM using curl:
In all cases above, subst 'i586' for 'x64' to download the 32-bit build.
curl
can be used in place ofwget
.UPDATE FOR JDK 7u79
TAR GZ:
RPM using curl:
Once again, make sure you specify the correct URL for the version you are downloading. You can find the URL here: Oracle JDK download site
ORIGINAL ANSWER FROM 9th June 2012
If you are looking to download the Oracle JDK from the command line using
wget
, there is a workaround. Run thewget
command as follows:Be sure to replace the download link with the correct one for the version you are downloading.
Instead of using for every new Java version a new link or changing existing scripts, I was looking for a more generic way to automate the download of the required Java packages and later installation via
yum localinstall ${JAVA_ENVIRONMENT}-${JAVA_VERSION}-linux-x64.rpm
.I've used a somehow trivial approach similar to manual/user action to find the package and to download it. I am also pretty sure that one will find a more elegant way to do it by using other tools like
egrep
,awk
, etc.., so leave it as an example here:Since the download links are available now, one may proceed further with
wget
orcurl
.