Download JDK from Oracle, playing nice with wget and curl

Annoying Licensing Agreement

Always painful that one has to accept "Licensing Agreement" before downloading JDK from oracle. It's not that hard to accept licence while downloading through a web browser. But, a lot of time you need to download to a server which doesn't have a web browser or a headless server.

So, How to download?

Pass cookie header oraclelicense with value accept-securebackup-cookie to the http request. Below is how to download through cURL and wget.

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

curl -LkO --header "Cookie: oraclelicense=accept-securebackup-cookie" ""