当我试图从Oracle下载Java时,我最终下载了一个页面,告诉我需要同意OTN许可条款。

对不起! 为了从Oracle技术网络下载产品,您必须同意OTN许可条款。 请务必…… 你的浏览器已经启用了“cookies”和JavaScript。 您点击了希望下载的产品的“接受许可”。 在接受许可后的30分钟内尝试下载。

如何下载及安装Java?


当前回答

此命令现已下载jdk8 TGZ包(2018-09-06),祝你好运!

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/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"

其他回答

截至2017-04-25,公认的答案对我不适用。然而,简单的解决方案是使用-b标志而不是——header选项。

例如,要获取jdk-1.8_131:

version='8u131'; wget -H -O jdk-$version-linux-x64.tar.gz --no-check-certificate --no-cookies -b "oraclelicense=a" http://download.oracle.com/otn-pub/java/jdk/$version-b11/jdk-$version-linux-x64.tar.gz

它将在后台执行,并将输出写入wget-log。

我已经为我的gentoo盒子制作了一个jdk-download脚本(特定于tar.gz)。不需要像其他类似的脚本那样更新,尝试“强制”下载您想要的任何版本的最新版本。

使用

jdk-download< <version> <platform> [<build>]

* <version> - Something like "8u40"
* <platform> - Usually i586 or x64
* <build> - The internal build number used by oracle, to avoid guessing and trying to download starting from 99 to 1 (build 0, really?!!)

博客

bitbucket源码

这适用于JDK 6,你只需要将下载url替换为最新版本。

wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk6-downloads-1637591.html;" http://download.oracle.com/otn-pub/java/jdk/6u33-b03/jdk-6u33-linux-x64.bin

适用于2021年12月23日的JDK 17

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/java/17/archive/jdk-17.0.1_linux-x64_bin.rpm

适用于2021年7月27日的JDK 16

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/16.0.2%2B7/d4a915d82b4c4fbb9bde534da945d746/jdk-16.0.2_linux-x64_bin.rpm

适用于2020年11月5日的JDK 15

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/15.0.1+9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_linux-x64_bin.rpm

适用于JDK 14 (07-11-2020)

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/14.0.1+7/664493ef4a6946b186ff29eb326336a2/jdk-14.0.1_linux-x64_bin.rpm -O ~/Downloads/jdk-14.0.1_linux-x64_bin.rpm

附:Alf加了这个(我):-)这个,我不知道怎么在最后评论…享受它。

更新为Oracle JDK 11

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/11+28/55eed80b163941c8885ad9298e6d786a/jdk-11_linux-x64_bin.tar.gz

针对JDK 10.0.2更新

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_linux-x64_bin.tar.gz

针对JDK 10.0.1更新

wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10.0.1+10/fb4372174a714e6b8c52526dc134031e/jdk-10.0.1_linux-x64_bin.tar.gz

针对JDK 9更新 看起来你现在可以直接从java.net下载它,而不需要发送头文件

wget http://download.java.net/java/GA/jdk9/9/binaries/jdk-9+181_linux-x64_bin.tar.gz

为JDK 8u191更新

焦油广州:

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3a%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk8-downloads-2133151.html; oraclelicense=accept-securebackup-cookie;" "https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz"

RPM:

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3a%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk8-downloads-2133151.html; oraclelicense=accept-securebackup-cookie;" "https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.rpm"

为JDK 8u131更新

RPM:

  wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm

焦油广州:

 wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz

使用旋度的RPM:

 curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm > jdk-8u112-linux-x64.rpm

在上述所有情况下,将'i586'替换为'x64'以下载32位版本。

-j ->垃圾饼干 -k ->忽略证书 - l -> follow重定向 - h [arg] ->头

Curl可以用来代替wget。

更新JDK 7u79

焦油广州:

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz

使用旋度的RPM:

curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm > jdk-7u79-linux-x64.rpm

同样,请确保您为正在下载的版本指定了正确的URL。您可以在这里找到URL: Oracle JDK下载站点

2012年6月9日的原稿

如果您希望使用wget从命令行下载Oracle JDK,有一种变通方法。执行wget命令如下:

wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz"

请确保将下载链接替换为您正在下载的版本的正确链接。

甲骨文在下载链接上放置了一个防止cookie,迫使你同意这些条款,尽管使用Java的许可协议明确规定,只要使用Java,你就“同意”了许可。

Oracle想要的方法是你下载它的时候有一个协议。在此之后,可以针对特定的Linux修改此脚本

#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
#Modify these variables as needed...
tempWork=/tmp/work
locBin=/usr/local/bin
javaUsrLib=/usr/lib/jvm

sudo mkdir -p $javaUsrLib
mkdir -p $tempWork
cd $tempWork

#Extract the download
tar -zxvf $downloadDir/jdk*tar.gz

#Move it to where it can be found...

sudo mv -f $tempWork/jdk* $javaUsrLib/

sudo ln -f -s $javaUsrLib/jdk1/bin/* /usr/bin/

#Update this line to reflect versions of JDK...
export JAVA_HOME="$javaUsrLib/jdk1.7.0_03"
#Extract the download
tar -zxvf $tempWork/*

#Move it to where it can be found...

sudo mv -f $tempWork/jdk1* $javaUsrLib/

sudo ln -f -s $javaUsrLib/jdk1*/bin/* /usr/bin/
sudo rm -rf $tempWork
#Update this line to reflect newer versions of JDK...
export JAVA_HOME="$javaUsrLib/jdk1.7.0_03"

if ! grep "JAVA_HOME=$javaUsrLib/jdk1.7.0_03" /etc/environment
then
    echo "JAVA_HOME=$javaUsrLib/jdk1.7.0_03"| sudo tee -a /etc/environment
fi


exit 0