Ubuntu – How to bypass the license page to download Oracle/Sun Java on a server with wget

command linejavaoraclewget

I'm trying to install Liferay on Ubuntu Server 12.04, which requires JRE and recommends version 6.

I can't find JRE6 in an authoritative repository, and I can't work out how to get past the licence agreement for a manual (wget) download.

Can I add a value to wget to accept the Oracle licence agreement and download the file?

Thanks

Best Answer

"Automated" Oracle Java Downloads (JRE/JDK 6/7 and others...)

You will need sqlite3 installed; it's a tiny package, use sudo apt-get install sqlite3 if you need to.

  1. Open Firefox, go to the Java downloads page for the version/variant you need, and click on the Accept License Agreement radio button.

    enter image description here

  2. Open a terminal, and paste this to extract the necessary Oracle session cookies from the Firefox SQLite cookie database into a cookies format text file wget can use (source for script):

    echo ".mode tabs
    select host, case when host glob '.*' then 'TRUE' else 'FALSE' end, path,
    case when isSecure then 'TRUE' else 'FALSE' end, expiry, name, value
    from moz_cookies;" | sqlite3 ~/.mozilla/firefox/*.default/cookies.sqlite
    | grep -i oracle > /tmp/oracle-cookies.txt
    
  3. Now use wget to download with those session cookies:

    wget --load-cookies=/tmp/oracle-cookies.txt wget http://download.oracle.com/otn-pub/java/jdk/6u14-b08/jdk-6u14-linux-x64.bin
    
  4. Notes:

    • You can use these cookies for any Oracle download as long as it comes from the otn-pub directory
    • You can paste the script in to a .sh file for easier use
    • The cookies are not associated with IP, so for a headless/CLI server, simply SCP or transfer the cookies file and you can download from any computer (but there is a 30-minute timeout on the cookie, so beware)
    • Related: How do I use wget/curl to download from a site I am logged into?
Related Question