title: wget/curl download of Oracle Java 7 SDK from the Oracle Archive page
body: <p>There are plenty of posts on StackOverflow and other communities (AskUbuntu, Unix &amp; Linux etc.) which provide advice on how to use <code>wget</code> or <code>cUrl</code> to automate downloading a Java distribution from the Oracle website. They all involve sending a cookie which pretends that one accepted the license agreement which one usually has to to manually before the real download link appears.</p>
  
  <p>However, none of these work for me when trying to download Java 7 SDK which recently has been moved to the <a href="http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html" rel="noreferrer">Oracle Archive page</a>.</p>
  
  <p>If I go to this page, accept the license agreement manually and then copy a download link, it looks like this:</p>
  
  <p><code>http://download.oracle.com/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz</code></p>
  
  <p><strong>Note that it has <code>otn</code> in the middle while all the other posts are about URLs which are stored under<code>otn-pub</code>.</strong></p>
  
  <p>Using the usual way that worked for the <code>otn-pub</code> links looks like this:</p>
  
  <p><code>wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=a" http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz</code></p>
  
  <p>However, this does not work for the <code>otn</code> type of URL. Instead, <code>wget</code> returns:</p>
  
  <pre><code>--2017-05-23 12:11:12--  http://download.oracle.com/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz
  Resolving download.oracle.com (download.oracle.com)... 92.122.214.233, 92.122.214.217
  Connecting to download.oracle.com (download.oracle.com)|92.122.214.233|:80... connected.
  HTTP request sent, awaiting response... 302 Moved Temporarily
  Location: https://edelivery.oracle.com/akam/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz [following]
  --2017-05-23 12:11:12--  https://edelivery.oracle.com/akam/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz
  Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.0.39.115, 2a02:26f0:8f:29a::2d3e
  Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.0.39.115|:443... connected.
  HTTP request sent, awaiting response... 302 Moved Temporarily
  Location: https://login.oracle.com/pls/orasso/orasso.wwsso_app_admin.ls_login?Site2pstoreToken=v1.2~CA55CD32~5B4FBD9FD4FC906722CB92CC3F7FA417B904138FD53F875C3FEFDF932EC5928D866C8B39EACAA55F28099E034BAC612F869C90A39B20E322E380F4A006B9668EAD35323A1C548EAD5D03EE8D6C772A88C049F024986DC6CCF546B00D347731F76BE786B96F0041610DEE7B6B4EAC27DCBE558B151B032973F065FC0367918B72DBCAB4B7FC920BAC4C13E820DFFE1761C5C473B6E0A4F0E94FABACDB40F02AD6B2BAB1D3F57371B14048557A0291AC3F12C73A30CAF4AAEB8A545475300A1ABBD60E2BF27FB1B11BC47DE91D0E918E04E4C4663632E98752BBC07671BBD21E7C6F73D78A8A66254579EC63B99716D999 [following]
  --2017-05-23 12:11:12--  https://login.oracle.com/pls/orasso/orasso.wwsso_app_admin.ls_login?Site2pstoreToken=v1.2~CA55CD32~5B4FBD9FD4FC906722CB92CC3F7FA417B904138FD53F875C3FEFDF932EC5928D866C8B39EACAA55F28099E034BAC612F869C90A39B20E322E380F4A006B9668EAD35323A1C548EAD5D03EE8D6C772A88C049F024986DC6CCF546B00D347731F76BE786B96F0041610DEE7B6B4EAC27DCBE558B151B032973F065FC0367918B72DBCAB4B7FC920BAC4C13E820DFFE1761C5C473B6E0A4F0E94FABACDB40F02AD6B2BAB1D3F57371B14048557A0291AC3F12C73A30CAF4AAEB8A545475300A1ABBD60E2BF27FB1B11BC47DE91D0E918E04E4C4663632E98752BBC07671BBD21E7C6F73D78A8A66254579EC63B99716D999
  Resolving login.oracle.com (login.oracle.com)... 209.17.4.8
  Connecting to login.oracle.com (login.oracle.com)|209.17.4.8|:443... connected.
  HTTP request sent, awaiting response... 401 Authorization Required
  
  Username/Password Authentication Failed.
  </code></pre>
  
  <p>Looks like either they changed something regarding the authentication or it never worked before for links from the <code>Oracle Archive</code> page (never tried that before).</p>
  
  <p>Any idea how I can download the most recent Oracle Java 7 SDK .tar.gz archive using <code>wget</code> or <code>cUrl</code> or similar?</p>