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?



6 Answers 6


"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?
  • 1
    Is it 100% legal?
    – Tachyons
    Aug 1, 2012 at 23:22
  • @tachyons Yes, you do have to open a browser on some computer and click on "Accept License Agreement" before you can do any of this...
    – ish
    Aug 1, 2012 at 23:24
  • Cool trick, but any idea if it still works? I keep trying it but it only downloads an html page content that says "Sorry! In order to download products from the OTN you must agree to the OTN license terms". Either I'm doing it wrong or Oracle got wise to this...
    – bgibson
    Aug 29, 2012 at 0:36
  • You can always just past that url into the browser as well :) Jul 1, 2016 at 12:03
  • While this answer is great, the one I just posted below is much easier. Of course, you may need to fall back to this one if mine stops working. Oct 30, 2016 at 15:45

There is a similar question on stackoverflow: How to automate download and instalation of Java JDK on Linux?

The answer using wget is:

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"

The last argument is the url to download from. Different java version archives differ not only in version, but extension too.

  • 2
    No longer works.
    – Roger Dahl
    Jan 14, 2016 at 16:40
  • yeah this doesn't work, keeps redirecting me to login.oracle.com May 20, 2019 at 21:04

A tip from mkyong.com: you can use wget --header "Cookie: oraclelicense=accept-securebackup-cookie" [link from download page] to download without needing to extract cookies from your browser.

  • This is clearly better than the other answers as long as it works. It is still the case at the time of this writing. Nov 23, 2017 at 14:30

As an addition to izx answer, there is a chrome plugin you can use to export your cookies, so you do not have to use sqlite.

  • @izx's answer is great. But I much prefer pushy's suggestion of using "Cookie.txt export" to get the cookie contents (corresponding to step 2 of izx's answer) rather than using sqlite3.
    – mdahlman
    Aug 6, 2013 at 21:34

A quick way with out cookies:

  • Start the download in your browser
  • Pause the download
  • Copy the url being used for the download
  • Use the url with wget: wget --no-check-certificate URL_FOR_DOWNLOAD

The URL is probably only valid for a limited amount of time (often 30minutes).


Actually, just get the content given by the chrome extension mentioned by pushy in a file on your linux. Then copy the dl adresse from oracle page and add it to your wget command. For example, to dl Oracle Database 11g Release 2 (

vagrant@vagrant-ubuntu-trusty-64:~/download$ wget -x --load-cookies cookies.txt http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .