Friday, April 14, 2017

Oracle Linux - Download Java JDK with wget

When working with Oracle Linux it might very well be that you do not have a graphical user interface. In case you need to download something most commonly you will be using wget or curl. In most cases that works perfecty fine, in some cases however this is not working as you might expect. One of the issues a lot of people complain about is that they want to download the java JRE or Java JDK from the Oracle website using wget or curl. When executing a standard wget command however they run into the issue that the response they get is not the rpm (or package) they want. Instead the content of the file is html.

Reason or this is that the page that controls the download works with cookies that force you to accept the license agreement prior to downloading. As you most likely will not have a graphical user interface you cannot use a browser to download it.

This holds that we need to trick the Oracle website in believing we have clicked the button to agree with the license agreement and serve the file instead of html code. The command you can use for this is shown below:

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"

We now instructed wget to send a header which states "Cookie: oraclelicense=accept-securebackup-cookie". This is the response needed by Oracle to serve the rpm file itself.

Now you can install the JDK by making use of the rpm -ivh command. This should ensure you have it installed on your Oracle Linux system.As a check you can execute the below version which should tell you exactly what is now installed on the system:

[root@localhost tmp]#
[root@localhost tmp]# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
[root@localhost tmp]#
[root@localhost tmp]#
Post a Comment