Saturday, March 31, 2012

Download Java JRE/JDK 7 from shell

A bit off-topic from this blog prespective but still wanted to share this as I couldn't find an answer to this.

I've been trying to install JRE 7 on my amazon ec2 server.
The first step to do so, is to wget (download) the rpm / bin install file, right?

Well it seems like since Java7, you must accept license agreement on the download page, before you can download java, which make sense. The problem with that is that you cannot accept this license agreement if you are on shell, doing wget.

[root@X opt]# wget http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jre-7u3-linux-x64.rpm
--2012-03-31 10:13:47--  http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jre-7u3-linux-x64.rpm
Resolving download.oracle.com... 67.148.147.41, 67.148.147.57
Connecting to download.oracle.com|67.148.147.41|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/7u3-b04/jre-7u3-linux-x64.rpm [following]
--2012-03-31 10:13:47--  https://edelivery.oracle.com/otn-pub/java/jdk/7u3-b04/jre-7u3-linux-x64.rpm
Resolving edelivery.oracle.com... 23.1.46.174
Connecting to edelivery.oracle.com|23.1.46.174|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/errors/download-fail-1505220.html [following]
--2012-03-31 10:13:47--  http://download.oracle.com/errors/download-fail-1505220.html
Connecting to download.oracle.com|67.148.147.41|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5307 (5.2K) [text/html]
Saving to: גdownload-fail-1505220.html.1ג
100%[==============================================================================================================================>] 5,307       --.-K/s   in 0.001s
2012-03-31 10:13:47 (3.40 MB/s) - גdownload-fail-1505220.html.1ג


So one way to work-around this is to download the file from a browser and copy over to the linux box, which for me, uploading 20MB file to amazon will take about half an hour or so..

The option I find to work around better for me is to run any network sniffer / IE developer tools / Chrome dev tools / etc and look for the final link which has the AuthParam=*.

So all you have to do now, is copy and paste this URL into your shell window like this:

[root@X opt]# wget http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jre-7u3-linux-x64.rpm?AuthParam=1333189254_3bd4c119fa6d0056c3661e50ebc8c521
--2012-03-31 10:19:17--  http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jre-7u3-linux-x64.rpm?AuthParam=1333189254_3bd4c119fa6d0056c3661e50ebc8c521
Resolving download.oracle.com... 67.148.147.57, 67.148.147.41
Connecting to download.oracle.com|67.148.147.57|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21283819 (20M) [application/x-redhat-package-manager]
Saving to: גjre-7u3-linux-x64.rpm?AuthParam=1333189254_3bd4c119fa6d0056c3661e50ebc8c521ג
100%[==============================================================================================================================>] 21,283,819  16.9M/s   in 1.2s
2012-03-31 10:19:18 (16.9 MB/s) - גjre-7u3-linux-x64.rpm?AuthParam=1333189254_3bd4c119fa6d0056c3661e50ebc8c521ג

Good luck!

As I see many people still coming for this topic, please use the better solution described here: http://ivan-site.com/2012/05/download-oracle-java-jre-jdk-using-a-script/

13 comments:

  1. ¡thank you so much!
    it worked for me with my own AuthParam

    ReplyDelete
  2. you could've named that firefox plugin for viewing links. because so much time being wasted for searching something similar.

    ReplyDelete
    Replies
    1. finally found one decent. called HttpFox

      https://addons.mozilla.org/en-US/firefox/addon/httpfox/

      Delete
  3. there's actually an easier way using just a single cookie header in wget - http://ivan-site.com/2012/05/download-oracle-java-jre-jdk-using-a-script/

    ReplyDelete
  4. Absolutely! Ivan's solution is the right one! thanks for posting this here. Now it can get fully automated, once again :)

    ReplyDelete
  5. Nice !

    Tks.

    Gudu
    wgudu@hotmail.com

    ReplyDelete
  6. Thanks it's working you saved my time

    ReplyDelete
  7. Very helpful. I appreciate it indeed!

    ReplyDelete
  8. Shumuel, thank you! I encountered the same case today, and had solved it by this article.

    ReplyDelete