Issue
Like said in the title, i'm trying to download the jdk installer in a batch file using the following command :
wget --verbose --show-progress --referer="https://download.oracle.com" --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn-pub/java/jdk/15.0.1%2B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.exe"
I get this error from the batch file:
--2021-01-05 15:12:30-- https://download.oracle.com/otn-pub/java/jdk/15.0.1B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.exe
Resolving download.oracle.com (download.oracle.com)... 23.212.156.99
Connecting to download.oracle.com (download.oracle.com)|23.212.156.99|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/15.0.1B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.exe [following]
--2021-01-05 15:12:30-- https://edelivery.oracle.com/otn-pub/java/jdk/15.0.1B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.exe
Resolving edelivery.oracle.com (edelivery.oracle.com)... 2a02:26f0:2b00:3b4::366, 2a02:26f0:2b00:390::366, 104.124.198.35
Connecting to edelivery.oracle.com (edelivery.oracle.com)|2a02:26f0:2b00:3b4::366|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://download.oracle.com/otn-pub/java/jdk/15.0.1B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.exe?AuthParam=1609856056_4a223d45cbb97da535473401552470f5 [following]
--2021-01-05 15:12:31-- https://download.oracle.com/otn-pub/java/jdk/15.0.1B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.exe?AuthParam=1609856056_4a223d45cbb97da535473401552470f5
Connecting to download.oracle.com (download.oracle.com)|23.212.156.99|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2021-01-05 15:12:32 ERROR 404: Not Found.
BUT
When I use this command line directly in the CLI (changing the CD where the wget.exe file resides), it downloads the installer properly, like the following :
--2021-01-05 15:19:43-- https://download.oracle.com/otn-pub/java/jdk/15.0.1%2B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.exe
Resolving download.oracle.com (download.oracle.com)... 23.212.156.99
Connecting to download.oracle.com (download.oracle.com)|23.212.156.99|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/15.0.1%2B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.exe [following]
--2021-01-05 15:19:43-- https://edelivery.oracle.com/otn-pub/java/jdk/15.0.1%2B9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.exe
Resolving edelivery.oracle.com (edelivery.oracle.com)... 2a02:26f0:2b00:390::366, 2a02:26f0:2b00:3b4::366, 104.126.235.187
Connecting to edelivery.oracle.com (edelivery.oracle.com)|2a02:26f0:2b00:390::366|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://download.oracle.com/otn-pub/java/jdk/15.0.1+9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.exe?AuthParam=1609856489_c1f5f2310bf675762561de7d78160532 [following]
--2021-01-05 15:19:44-- https://download.oracle.com/otn-pub/java/jdk/15.0.1+9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_windows-x64_bin.exe?AuthParam=1609856489_c1f5f2310bf675762561de7d78160532
Connecting to download.oracle.com (download.oracle.com)|23.212.156.99|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 167452312 (160M) [application/octet-stream]
Saving to: 'jdk-15.0.1_windows-x64_bin.exe'
I really need to use this command a script.
If anyone knew what could have gone wrong between the batch file and the CLI, I'd be really thankful for the help.
Solution
Compare the URLs from your output.
The CLI URL contains a percentage sign %2B
as part of a URL-encoded letter. But the batch script output is missing this percentage sign, therefore leading to a wrong URL.
- CLI output
15.0.1%2B9
- Batch output
15.0.1B9
Since batch uses the percentage sign %
to identify variables you have to escape it, if you want to use it literally.
Therefore, try using two percentage signs in your batch script %%
. This should lead to a (correct) single %
in your URL.
Answered By - pscheid