Downloading Java JDK on Linux via wget is shown license page instead

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?


    UPDATED FOR JDK 9 it looks like you can download it now directly from java.net without sending a header

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

    UPDATED FOR JDK 8u151

    TAR GZ:

    wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz
    

    UPDATED FOR JDK 8u151

    TAR GZ:

    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/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz"
    

    RPM:

    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/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.rpm"
    

    UPDATED FOR 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 -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.

  • -j -> junk cookies
  • -k -> ignore certificates
  • -L -> follow redirects
  • -H [arg] -> headers
  • curl can be used in place of wget .

    UPDATE FOR 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 -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

    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 the wget command as follows:

    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.


    (Irani updated to my answer, but here's to clarify it all.)

    Edit: Updated for Java 10.0.1, released in 18th April

    Wget

    wget -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
    

    JRE 8u171 (no cookie flags): http://javadl.oracle.com/webapps/download/AutoDL?BundleId=233162_512cd62ec5174c3487ac17c61aaa89e8
    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 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

    curl -L -C - -b "oraclelicense=accept-securebackup-cookie" -O http://download.oracle.com/otn-pub/java/jdk/10.0.1+10/fb4372174a714e6b8c52526dc134031e/jdk-10.0.1_linux-x64_bin.tar.gz
    
  • -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).


  • 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.

    链接地址: http://www.djcxy.com/p/49160.html

    上一篇: 在Java中加密并在C#中解密用于AES 256位

    下一篇: 通过wget在Linux上下载Java JDK将显示许可页面