通过 wget 在 Linux 上下载 Java JDK 会显示许可证页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10268583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Downloading Java JDK on Linux via wget is shown license page instead
提问by thejartender
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.
当我尝试从 Oracle 下载 Java 时,我最终下载了一个页面,告诉我我需要同意 OTN 许可条款。
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.
对不起!
要从 Oracle 技术网下载产品,您必须同意 OTN 许可条款。
确定...
- 您的浏览器启用了“cookies”和 JavaScript。
- 您单击了要下载的产品的“接受许可”。
- 您在接受许可后 30 分钟内尝试下载。
How can I download and install Java?
如何下载和安装Java?
采纳答案by Eric Kamara
UPDATED FOR Oracle JDK 11
针对 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
UPDATED FOR JDK 10.0.2
为 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
UPDATED FOR JDK 10.0.1
为 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
UPDATED FOR JDK 9it looks like you can download it now directly from java.net without sending a header
更新了 JDK 9看起来您现在可以直接从 java.net 下载它而无需发送标头
wget http://download.java.net/java/GA/jdk9/9/binaries/jdk-9+181_linux-x64_bin.tar.gz
UPDATED FOR JDK 8u191
为 JDK 8u191 更新
TAR GZ:
焦油广州:
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"
UPDATED FOR JDK 8u131
为 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
TAR GZ:
焦油广州:
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 using curl:
使用 curl 的 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
In all cases above, subst 'i586' for 'x64' to download the 32-bit build.
在上述所有情况下,将 'i586' 替换为 'x64' 以下载 32 位版本。
- -j-> junk cookies
- -k-> ignore certificates
- -L-> follow redirects
- -H [arg]-> headers
- -j-> 垃圾饼干
- -k-> 忽略证书
- -L-> 按照重定向
- -H [arg]-> 标题
curl
can be used in place of wget
.
curl
可以代替wget
.
UPDATE FOR JDK 7u79
JDK 7u79 的更新
TAR GZ:
焦油广州:
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 using curl:
使用 curl 的 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
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
再次确保为正在下载的版本指定正确的 URL。您可以在此处找到 URL:Oracle JDK 下载站点
ORIGINAL ANSWER FROM 9th June 2012
2012 年 6 月 9 日的原始答复
If you are looking to download the Oracle JDK from the command line using wget
, there is a workaround. Run the wget
command as follows:
如果您想从命令行使用 下载 Oracle JDK wget
,有一个解决方法。运行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"
Be sure to replace the download link with the correct one for the version you are downloading.
请务必将下载链接替换为您正在下载的版本的正确链接。
回答by thejartender
Oracle has put a prevention cookie on the download link to force you to agree to the terms even though the license agreement to use Java clearly states that merely by using Java you 'agree' to the license..
Oracle 已在下载链接上放置了一个预防 cookie,以强制您同意这些条款,即使使用 Java 的许可协议明确指出,仅使用 Java 您就“同意”许可。
The method that Oracle wants is you to download it with an agreement. After that, this script cn be modified for your specific Linux
Oracle 想要的方法是你用协议下载它。之后,此脚本 cn 将针对您的特定 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
回答by Hiro2k
This works for the JDK 6, you just need to replace the download url with the latest version.
这适用于 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
回答by Andrew Gilmartin
Downloading Java from the command line has always been troublesome. What I have been doing reciently is to use FireFox (other browsers might work) to get a download started on my laptop, pause it (within the Downloads windows), use the "Copy Download Link" menu item of the context menu displayed for the downloading file. This URL can then be used on the Linux box to download the same file. I expect the URL has a short time to live. Ugly, but generally successful.
从命令行下载 Java 一直很麻烦。我一直在做的是使用 FireFox(其他浏览器可能工作)在我的笔记本电脑上开始下载,暂停它(在下载窗口中),使用显示的上下文菜单的“复制下载链接”菜单项下载文件。然后可以在 Linux 机器上使用此 URL 下载相同的文件。我希望 URL 的存活时间很短。丑陋,但总体上是成功的。
回答by sorin
I know that Oracle made everything possible to make their Java Runtime and Java SDK as hard as possible.
我知道 Oracle 尽一切可能使他们的 Java 运行时和 Java SDK 尽可能地困难。
Here are some guides for command line lovers.
这里有一些命令行爱好者的指南。
For Debian like systems (tested on Debian
squeeze and Ubuntu
12.x+)
对于类似 Debian 的系统(在Debian
Squeeze 和Ubuntu
12.x+上测试)
su -
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
apt-get install --yes oracle-java7-installer
exit
Note: if you know a better or easier way add a comment, I will update the guide.
注意:如果您知道更好或更简单的方法添加评论,我会更新指南。
回答by Jason Xu
latest tested,
最新测试,
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "https://edelivery.oracle.com/otn-pub/java/jdk/7u25-b15/jdk-7u25-linux-x64.tar.gz"
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" " https://edelivery.oracle.com/otn-pub/java/ jdk/7u25-b15/jdk-7u25-linux-x64.tar.gz"
Be aware that certificate check is disabled if you care about absolute security. : )
请注意,如果您关心绝对安全,则会禁用证书检查。:)
回答by Hymantrades
Why not click to download from your browser then copy & paste the exact link where it was downloaded, for example:
为什么不点击从浏览器下载,然后复制并粘贴下载的确切链接,例如:
wget http://download.oracle.com/otn-pub/java/jdk/7u40-b43/jdk-7u40-linux-x64.tar.gz?AuthParam=1380225131_dd70d2038c57a4729d8c0226684xxxx
You can find out the link by looking at the network tab of your browser after accepting terms in oracle and clicking to download. F12 in Chrome. Firebug in Firefox.
在oracle中接受条款并点击下载后,您可以通过查看浏览器的网络选项卡找到链接。Chrome 中的 F12。Firefox 中的萤火虫。
回答by nmeegama
sudo wget --no-check-certificate --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.rpm"
回答by tfewster
All of the above seem to assume you know the URL for the latest Java RPM...
以上所有内容似乎都假设您知道最新 Java RPM 的 URL...
Oracle provide persistent links to the latestupdates of each Java version as documented at https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=397248601136938&id=1414485.1- though you need to create/log in to an Oracle Support account. *Otherwise you can only access the last "public" update of each Java version, e.g. 1.6_u45 (Mar 2013; Latest update is u65, Oct 2013)*
Oracle 提供每个 Java 版本的最新更新的持久链接,如 https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=397248601136938&id=1414485.1 所述- 尽管您需要创建/登录到 Oracle 支持帐户. *否则您只能访问每个 Java 版本的最后一个“公开”更新,例如 1.6_u45(2013 年 3 月;最新更新为 2013 年 10 月的 u65)*
Once you knowthe persistent link, you should be able to resolve it to the real download; The following works for me, though I don't yet know if the "aru" reference changes.
一旦你知道持久链接,你应该能够将其解析为真正的下载;以下对我有用,但我还不知道“aru”参考是否改变。
ME=<myOracleID>
PW=<myOraclePW>
PATCH_FILE=p13079846_17000_Linux-x86-64.zip
echo "Get real URL from the persistent link"
wget -o getrealurl.out --no-cookies --no-check-certificate --user=$ME \
--password=$PW --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" \
https://updates.oracle.com/Orion/Services/download/$PATCH_FILE?aru=16884382&\
patch_file=$PATCH_FILE
wait # wget appears to go into background, so "wait" waits
# until all background processes complete
REALURL=`grep "^--" getrealurl.out |tail -1 |sed -e 's/.*http/http/'`
wget -O $PATCH_FILE $REALURL
#These last steps must be done quickly, as the REALURL seems to have a short-lived
#cookie on it and I've had no success with --keep-session-cookies etc.
回答by ssgao
Try
尝试
wget --no-cookies --header "Cookie: s_nr=1359635827494; s_cc=true; gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk6downloads-1902814.html; s_sq=%5B%5BB%5D%5D; gpv_p24=no%20value" http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64-rpm.bin --no-check-certificate -O ./jdk-6u45-linux-x64-rpm.bin
if you are like me trying to get Oracle JDK 6.
如果你像我一样试图获得 Oracle JDK 6。