HOWTO: Download Oracle Java Releases from the Commandline

Monday, January 14th, 2013 at 3:13 pm | 17,981 views | trackback url
Tags: ,

Oracle Sun logo
The recent and critical Java CVE necessitates that everyone either uninstall, remove or update Java immediately.

My employer uses a lot of Java, and removing or uninstalling it across thousands of machines just isn’t possible. We also support 4 platforms for each new release (in 32-bit and 64-bit), so pushing out a new version of Java involves downloading, unpacking, deploying and releasing 8 different builds per version. Today’s recent news, means I have to download and deploy 16 separate builds of Java for 1.6u38 and 1.7u11 to meet the security requirements and keep us current.

Oracle’s website is painful enough to navigate, and downloading new Java releases from their site requires an interactive click-wrap agreement to be acknowledged before you can continue with the process; before the download links become visible or active in a browser to be clicked. When you attempt to download, you’ll be presented with a page that contains this:

Oracle Java Download Clickwrap agreement

To download an Oracle Java release from here, you have to go to their Oracle Java Download page, click “Accept License Agreement”, and then click each version of Java you want to download, to download interactively using your desktop browser to your desktop.

In a word: Ugh.

If you need to use those on a UNIX or Linux host as I do, you then have to then take those downloads that you’ve pulled with your browser, and scp/pscp (with PuTTY or similar) or rsync those over to your UNIX/Linux machine from your desktop.

Could this process possibly be more convoluted and complicated?

But there’s a solution: Wget! (with some secret sauce)To download these directly to your UNIX/Linux machine, avoiding the click-wrap + download + scp/pscp/rsync business altogether, follow these steps:

  1. Visit the Oracle Java Download page in your browser.
  2. Select the version of Java you wish to download releases for (JDK or JRE)
  3. Click the “Accept License Agreement” radio button to “activate” the download links (buried behind Javascript on their page). Unfortunately this is required at this point.
  4. Right-click on the link of the download you need and copy it to your clipboard as shown here:

    Oracle right-click to copy

  5. Go to your UNIX or Linux machine in your shell, and run the following Wget command (all on one line):
    wget --no-check-certificate \
         --no-cookies           \
         --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" \
         "your_Oracle_download_link_from_right-click_here_in_quotes"
    $ wget --no-check-certificate --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" 
          "http://download.oracle.com/otn-pub/java/jdk/7u11-b21/jdk-7u11-linux-x64.tar.gz"
    --2013-01-14 12:08:35--  http://download.oracle.com/otn-pub/java/jdk/7u11-b21/jdk-7u11-linux-x64.tar.gz
    Location: https://edelivery.oracle.com/otn-pub/java/jdk/7u11-b21/jdk-7u11-linux-x64.tar.gz [following]
    --2013-01-14 12:08:36--  https://edelivery.oracle.com/otn-pub/java/jdk/7u11-b21/jdk-7u11-linux-x64.tar.gz
    WARNING: cannot verify edelivery.oracle.com's certificate, issued 
             by `/C=US/O=Akamai Technologies Inc/CN=Akamai Subordinate CA 3':
             Unable to locally verify the issuer's authority.
    Location: http://download.oracle.com/otn-pub/java/jdk/7u11-b21/jdk-7u11-linux-x64.tar.gz?AuthParam=1358183435_0f6b9771878843e64d7b79e67e22c0e7 [following]
    --2013-01-14 12:08:36--  http://download.oracle.com/otn-pub/java/jdk/7u11-b21/jdk-7u11-linux-x64.tar.gz?AuthParam=1358183435_0f6b9771878843e64d7b79e67e22c0e7
    Length: 97470187 (93M) [application/x-gzip]
    Saving to: `jdk-7u11-linux-x64.tar.gz?AuthParam=1358183435_0f6b9771878843e64d7b79e67e22c0e7'
    
    100%[===========================================================================================================>] 97,470,187  8.48M/s   in 13s
    
    2013-01-14 12:08:49 (7.18 MB/s) - `jdk-7u11-linux-x64.tar.gz?AuthParam=1358183435_0f6b9771878843e64d7b79e67e22c0e7' saved [97470187/97470187]

    Note the following part of that command; this is the magic.

    --no-check-certificate --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com"
  6. Once downloaded, you’ll have a file that has a filename like this:
     jdk-7u11-linux-x64.tar.gz\?AuthParam\=1358183435_0f6b9771878843e64d7b79e67e22c0e7

    You’ll want to move that to a new filename if you want to process it with any sort of tools or scripts.

  7. mv the file using your UNIX/Linux system’s tab completion (assuming Bash here), as follows:
    mv jdk-7u11-linux-x64.tar.gz\?AuthParam\=1358183435_0f6b9771878843e64d7b79e67e22c0e7 jdk-7u11-linux-x64.tar.gz

That’s it. Now you should be able to use your Java releases directly from your UNIX or Linux environment, without trampolining them across your desktop machine to get them there first.

Email me if you get stuck and I’ll give you a hand out of this mess.

Last Modified: Sunday, March 6th, 2016 @ 05:09

One Response to “HOWTO: Download Oracle Java Releases from the Commandline”

  1. Thank you sir, very helpful article.


Leave a Reply

You must be logged in to post a comment.

Bad Behavior has blocked 1916 access attempts in the last 7 days.