Download Oracle Java JRE & JDK using a script


转自:http://ivan-site.com/2012/05/download-oracle-java-jre-jdk-using-a-script/
Oracle has recently disallowed direct downloads of java from their servers (without going through the browser and agreeing to their terms, which you can look at here: http://www.oracle.com/technetwork/java/javase/terms/license/index.html ). So, if you try to wget http://download.oracle.com/otn-pub/java/jdk/7u4-b20/jdk-7u4-linux-x64.tar.gz you will receive a page with “In order to download products from Oracle Technology Network you must agree to the OTN license terms” error message.
This can be rather troublesome for setting up servers with automated scripts.
Luckily, it seems that a single cookie is all that is needed to bypass this (you still have to agree to the terms to install):
Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F
So, if you you want to download jdk7u4 for 64-bit Linux (e.g., Ubuntu) using wget, you can use:
1
2
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" \
"http://download.oracle.com/otn-pub/java/jdk/7u4-b20/jdk-7u4-linux-x64.tar.gz"

Just for reference, here are the links to the current (at the time of posting) downloads of JDK and JRE
UPDATE: instead of having new post for each JDK/JRE update I’ll just keep updating this one

你可能感兴趣的:(java,linux,脚本,下载)