解决 wget 无法下载 oracle JDK 的问题

Linux 安装 JDK 报错 error open of/no such file or directory

解决无法使用 wget 下载 oracle JDK 的问题

出现问题

如果直接在 oracle 官网复制下载链接,然后在 linux 上使用 wget 下载,再安装的时候就会出现这样的错误:

# rpm -ivh jdk-7u25-linux-x64.rpm
error: open of <html> failed: No such file or directory
error: open of <head> failed: No such file or directory
error: open of <title>Unauthorized failed: No such file or directory
error: open of Request</title> failed: No such file or directory
error: open of <META failed: No such file or directory
error: open of NAME=ROBOTS failed: No such file or directory
error: open of CONTENT=NOINDEX, NOFOLLOW> failed: No such file or directory
error: open of <link failed: No such file or directory
error: open of rel=stylesheet failed: No such file or directory
error: open of type=text/css failed: No such file or directory
error: open of href=/errors/us/assets/hp-styles.css failed: No such file or directory
error: open of /> failed: No such file or directory
error: open of <link failed: No such file or directory
error: open of rel=stylesheet failed: No such file or directory
error: open of type=text/css failed

问题原因

oracle 前段时间声明,现在从网页上下载 jdk,需要一个特殊的 cookies,所以直接用 wget 下载下来的文件会有问题。其实上面的方式下载下来的只是一个网页。

解决方案

使用下面的命令下载,

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/7u4-b20/jdk-7u4-linux-x64.tar.gz"

上面后面的软件版本可以从下面列表里替换

JDK 8u25

http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-i586.rpm
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-i586.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.rpm
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-macosx-x64.dmg
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-solaris-sparcv9.tar.Z
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-solaris-sparcv9.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-solaris-x64.tar.Z
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-solaris-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b18/jdk-8u25-windows-i586.exe
http://download.oracle.com/otn-pub/java/jdk/8u25-b18/jdk-8u25-windows-x64.exe
JDK 7u72

http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-linux-i586.rpm
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-linux-i586.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-linux-x64.rpm
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-linux-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-macosx-x64.dmg
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-solaris-i586.tar.Z
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-solaris-i586.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-solaris-x64.tar.Z
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-solaris-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-solaris-sparc.tar.Z
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-solaris-sparc.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-solaris-sparcv9.tar.Z
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-solaris-sparcv9.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-windows-i586.exe
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-windows-x64.exe
JRE 8u25

http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-linux-i586.rpm
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-linux-i586.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-linux-x64.rpm
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-linux-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-macosx-x64.dmg
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-macosx-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-solaris-sparcv9.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jre-8u25-solaris-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b18/jre-8u25-windows-i586-iftw.exe
http://download.oracle.com/otn-pub/java/jdk/8u25-b18/jre-8u25-windows-i586.exe
http://download.oracle.com/otn-pub/java/jdk/8u25-b18/jre-8u25-windows-i586.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b18/jre-8u25-windows-x64.exe
http://download.oracle.com/otn-pub/java/jdk/8u25-b18/jre-8u25-windows-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/server-jre-8u25-linux-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/server-jre-8u25-solaris-sparcv9.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b17/server-jre-8u25-solaris-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/8u25-b18/server-jre-8u25-windows-x64.tar.gz
JRE 7u72

http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-linux-i586.rpm
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-linux-i586.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-linux-x64.rpm
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-linux-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-macosx-x64.dmg
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-macosx-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-solaris-i586.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-solaris-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-solaris-sparc.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-solaris-sparcv9.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-windows-i586-iftw.exe
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-windows-i586.exe
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-windows-i586.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-windows-x64.exe
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jre-7u72-windows-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/server-jre-7u72-linux-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/server-jre-7u72-solaris-i586.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/server-jre-7u72-solaris-sparc.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/server-jre-7u72-solaris-sparcv9.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/server-jre-7u72-solaris-x64.tar.gz
http://download.oracle.com/otn-pub/java/jdk/7u72-b14/server-jre-7u72-windows-x64.tar.gz

参考: 网址