I have created an image doing the following command :
wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.2.1.tgz
So I commented this command, and directly went in my image to do the command. However, the wget fails, with the following message :
wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.tgz
converted 'https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.tgz' (ANSI_X3.4-1968) -> 'https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.tgz' (UTF-8)
--2020-04-22 12:24:57-- https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.tgz
Resolving archive.apache.org (archive.apache.org)... 138.201.131.134, 2a01:4f8:172:2ec5::2
Connecting to archive.apache.org (archive.apache.org)|138.201.131.134|:443... connected.
ERROR: The certificate of 'archive.apache.org' is not trusted.
ERROR: The certificate of 'archive.apache.org' hasn't got a known issuer.
Am I missing something basic with WGET ?
Thank you in advance for your help.
First try to get proper certificate manager installed like below:
sudo apt-get install ca-certificates //. command dependent on linux distro , please correct according to distro use
If you don't care about certificate , then you can pass following param with wget:
--no-check-certificate
like below:
wget --no-check-certificate https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.tgz
Note:- It's insecure option and can lead to Security Vulnerability.
Adding --no-check-certificate to the wget command could do the trick, but I don't recommend you to do it.
What base Docker image are you using? Maybe the ca-certificates package is not installed or is outdated.
For some research purpose, I want to download 1000 java classes (".java") files from the given website. I don't want to do this manually.
For example, below has many Java Source files which I want to get using scripting/programming. I've worked with Linux shell scripts, PHP, and Java. So any solution using these is appreciated.
http://www.cs.uic.edu/~sloan/CLASSES/java/
Thanks!
Based on the question
wget -A java -r https://www.cs.uic.edu/~sloan/CLASSES/java/
will download all ".java" files in the same directory structure as on the server.
This will also download the robots.txt file.
For the particular example you gave,
curl -vs https://www.cs.uic.edu/~sloan/CLASSES/java/ 2>&1 | grep -oP '(?<=").*.java(?=")' | sed -e 's|^|https://www.cs.uic.edu/~sloan/CLASSES/java/|' | xargs wget
Explanations
1) Get the page and print to stdout. It will give you entire html.
curl -vs https://www.cs.uic.edu/~sloan/CLASSES/java/ 2>&1
2) Find the word with .java in quotes, but output without quotes "[ANYTHING].java". It will give you something like HelloWorld.java.
grep -oP '(?<=").*.java(?=")'
3) Add prefix to make it full url, so you can download them. It will give you something like https://www.cs.uic.edu/~sloan/CLASSES/java/HelloWorld.java
sed -e 's|^|https://www.cs.uic.edu/~sloan/CLASSES/java/|'
4) Download them to the current directory.
xargs wget
Thank you all !!
I've done using "wget -r -l1 -nd -nc -A.java http://www.cs.uic.edu/~sloan/CLASSES/java/"
This was however my required task. But am just thinking, may be we can improve same "wget" to go on internet and get me 1000 ".java" files. Perhaps, we can invoke google search (from script) for a keyword "java tutorials" and then from the returned URL, scan for ".java" files.
Thank again all
Viki.
When I try to download Java from Oracle I instead end up downloading a page telling me that I need agree to the OTN license terms.
Sorry!
In order to download products from Oracle Technology Network you must agree to the OTN license terms.
Be sure that...
Your browser has "cookies" and JavaScript enabled.
You clicked on "Accept License" for the product you wish to download.
You attempt the download within 30 minutes of accepting the license.
How can I download and install Java?
Works as of December 23rd, 2021 for JDK 17
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/java/17/archive/jdk-17.0.1_linux-x64_bin.rpm
Works as of July 27th, 2021 for JDK 16
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/16.0.2%2B7/d4a915d82b4c4fbb9bde534da945d746/jdk-16.0.2_linux-x64_bin.rpm
Works as of November 5th, 2020 for JDK 15
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/15.0.1+9/51f4f36ad4ef43e39d0dfdbaf6549e32/jdk-15.0.1_linux-x64_bin.rpm
Works as of 07-11-2020 for JDK 14
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/14.0.1+7/664493ef4a6946b186ff29eb326336a2/jdk-14.0.1_linux-x64_bin.rpm -O ~/Downloads/jdk-14.0.1_linux-x64_bin.rpm
PS: Alf added this ( me ) :-) this, I couldn't figured out how to just commented at the end... Enjoy it.
UPDATED FOR Oracle JDK 11
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/11+28/55eed80b163941c8885ad9298e6d786a/jdk-11_linux-x64_bin.tar.gz
UPDATED FOR JDK 10.0.2
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_linux-x64_bin.tar.gz
UPDATED FOR JDK 10.0.1
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10.0.1+10/fb4372174a714e6b8c52526dc134031e/jdk-10.0.1_linux-x64_bin.tar.gz
UPDATED FOR JDK 9
it looks like you can download it now directly from java.net without sending a header
wget http://download.java.net/java/GA/jdk9/9/binaries/jdk-9+181_linux-x64_bin.tar.gz
UPDATED FOR JDK 8u191
TAR GZ:
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3a%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk8-downloads-2133151.html; oraclelicense=accept-securebackup-cookie;" "https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz"
RPM:
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3a%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk8-downloads-2133151.html; oraclelicense=accept-securebackup-cookie;" "https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.rpm"
UPDATED FOR JDK 8u131
RPM:
wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
TAR GZ:
wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
RPM using curl:
curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm > jdk-8u112-linux-x64.rpm
In all cases above, subst 'i586' for 'x64' to download the 32-bit build.
-j -> junk cookies
-k -> ignore certificates
-L -> follow redirects
-H [arg] -> headers
curl can be used in place of wget.
UPDATE FOR JDK 7u79
TAR GZ:
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz
RPM using curl:
curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm > jdk-7u79-linux-x64.rpm
Once again, make sure you specify the correct URL for the version you are downloading. You can find the URL here: Oracle JDK download site
ORIGINAL ANSWER FROM 9th June 2012
If you are looking to download the Oracle JDK from the command line using wget, there is a workaround. Run the wget command as follows:
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz"
Be sure to replace the download link with the correct one for the version you are downloading.
(Irani updated to my answer, but here's to clarify it all.)
Edit: Updated for Java 17.0.1, released in 19th October, 2021
Wget
wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
See the downloads in oracle.com for more.
-c / --continue
Allows continuing an unfinished download.
--header "Cookie: oraclelicense=accept-securebackup-cookie"
Since 15th March 2014 this cookie is provided to the user after accepting the License Agreement and is necessary for accessing the Java packages in download.oracle.com. The previous (and first) implementation in 27th March 2012 made use of the cookie gpw_e24=http%3A%2F%2Fwww.oracle.com[...]. Both cases remain unannounced to the public.
The value doesn't have to be "accept-securebackup-cookie".
Not required
--no-cookies
The combination --no-cookies --header "Cookie: name=value" is mentioned as the "official" cookie support, but not strictly required here.
cURL
curl -L -C - -b "oraclelicense=accept-securebackup-cookie" -O https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
-L / --location
Required for cURL to redirect through all the mirrors.
-C / --continue-at -
See above. cURL requires the dash (-) in the end.
-b / --cookie "oraclelicense=accept-securebackup-cookie"
Same as -H / --header "Cookie: ...", but accepts files too.
-O
Required for cURL to save files (see [author's comparison][8] for more differences).
Downloading Java from the command line has always been troublesome. What I have been doing reciently is to use FireFox (other browsers might work) to get a download started on my laptop, pause it (within the Downloads windows), use the "Copy Download Link" menu item of the context menu displayed for the downloading file. This URL can then be used on the Linux box to download the same file. I expect the URL has a short time to live. Ugly, but generally successful.
Updated for JDK 8u171 RPM
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.rpm
Outdated links below
Updated for JDK 8u161 RPM
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm
Updated for JDK 8u152 RPM
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/jdk-8u152-linux-x64.rpm
Updated for JDK 8u144 RPM
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm
Updated for JDK 8u131 RPM
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
Updated for JDK 8u121 RPM
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.rpm
I know that Oracle made everything possible to make their Java Runtime and Java SDK as hard as possible.
Here are some guides for command line lovers.
For Debian like systems (tested on Debian squeeze and Ubuntu 12.x+)
su -
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
apt-get install --yes oracle-java7-installer
exit
Note: if you know a better or easier way add a comment, I will update the guide.
There is a good alternative for installing different JDK from the command line ... using https://sdkman.io/ there are plenty of vendedors
sdk install java 19.0.1-oracle
latest tested,
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "https://edelivery.oracle.com/otn-pub/java/jdk/7u25-b15/jdk-7u25-linux-x64.tar.gz"
Be aware that certificate check is disabled if you care about absolute security. : )
Oracle has put a prevention cookie on the download link to force you to agree to the terms even though the license agreement to use Java clearly states that merely by using Java you 'agree' to the license..
The method that Oracle wants is you to download it with an agreement. After that, this script cn be modified for your specific Linux
#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
#Modify these variables as needed...
tempWork=/tmp/work
locBin=/usr/local/bin
javaUsrLib=/usr/lib/jvm
sudo mkdir -p $javaUsrLib
mkdir -p $tempWork
cd $tempWork
#Extract the download
tar -zxvf $downloadDir/jdk*tar.gz
#Move it to where it can be found...
sudo mv -f $tempWork/jdk* $javaUsrLib/
sudo ln -f -s $javaUsrLib/jdk1/bin/* /usr/bin/
#Update this line to reflect versions of JDK...
export JAVA_HOME="$javaUsrLib/jdk1.7.0_03"
#Extract the download
tar -zxvf $tempWork/*
#Move it to where it can be found...
sudo mv -f $tempWork/jdk1* $javaUsrLib/
sudo ln -f -s $javaUsrLib/jdk1*/bin/* /usr/bin/
sudo rm -rf $tempWork
#Update this line to reflect newer versions of JDK...
export JAVA_HOME="$javaUsrLib/jdk1.7.0_03"
if ! grep "JAVA_HOME=$javaUsrLib/jdk1.7.0_03" /etc/environment
then
echo "JAVA_HOME=$javaUsrLib/jdk1.7.0_03"| sudo tee -a /etc/environment
fi
exit 0
For those needing JCE8 as well, you can download that also.
curl -L -C - -b "oraclelicense=accept-securebackup-cookie" -O http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip
Or
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip
This works for the JDK 6, you just need to replace the download url with the latest version.
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk6-downloads-1637591.html;" http://download.oracle.com/otn-pub/java/jdk/6u33-b03/jdk-6u33-linux-x64.bin
this command can download jdk8 tgz package at now (2018-09-06), good luck !
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"
Instead of using for every new Java version a new link or changing existing scripts, I was looking for a more generic way to automate the download of the required Java packages and later installation via yum localinstall ${JAVA_ENVIRONMENT}-${JAVA_VERSION}-linux-x64.rpm.
I've used a somehow trivial approach similar to manual/user action to find the package and to download it. I am also pretty sure that one will find a more elegant way to do it by using other tools like egrep, awk, etc.., so leave it as an example here:
#!/bin/bash
### Proxy settings
# If there is a company proxy
PROXY="my.proxy.local:8080"
PROXY_TYPE="--proxy-ntlm" # or leave empty with ""
USER="user"
PASS='pass'
### Find out the links to JRE and JDK
# To do so, got to the page http://www.oracle.com/technetwork/java/javase/downloads/
BASE_URL="technetwork/java/javase/downloads"
# Put the whole page into a single string/line
BASE_URL_OUTPUT="$(curl -s -k ${PROXY_TYPE} -x "http://${USER}:${PASS}#${PROXY}" -L0 http://www.oracle.com/${BASE_URL}/)"
# Define the environments to download
JAVA_ENVIRONMENTS=("JRE" "JDK") # ! yet "SERVER-JRE"
for JAVA_ENVIRONMENT in "${JAVA_ENVIRONMENTS[#]}"
do
echo
echo "JAVA_ENVIRONMENT="$JAVA_ENVIRONMENT
echo
for (( JAVA_BASE_VERSION = 8; JAVA_BASE_VERSION <= 10; JAVA_BASE_VERSION += 2 ))
do
echo "JAVA_BASE_VERSION="$JAVA_BASE_VERSION
### "Read the page"
# and follow the links for the package interested in
DOWNLOAD_SITE="$(echo $BASE_URL_OUTPUT | grep -m 1 -io "${JAVA_ENVIRONMENT}${JAVA_BASE_VERSION}-downloads-[0-9]*.html" -- | tail -1)"
echo "DOWNLOAD_SITE="$DOWNLOAD_SITE
### Gather the necessary download links
# To do so, following the link to the download site
# reading and accept the license
#
# ... the greedy regular expression is to address the different syntax of the links
# and already prepared for OR .gz files
DOWNLOAD_LINK_OUTPUT="$(curl -s -k ${PROXY_TYPE} -x "http://${USER}:${PASS}#${PROXY}" -L -j -H "Cookie: oraclelicense=accept-securebackup-cookie" http://www.oracle.com/${BASE_URL}/${DOWNLOAD_SITE} | grep -io "filepath.*${JAVA_ENVIRONMENT}-[${JAVA_BASE_VERSION}].*linux[-_]x64[._].*\(rpm\)" -- | cut -d '"' -f 3 | tail -1)"
# and echo out the link
echo "DOWNLOAD_LINK_OUTPUT="$DOWNLOAD_LINK_OUTPUT
done
done
Since the download links are available now, one may proceed further with wget or curl.
All of the above seem to assume you know the URL for the latest Java RPM...
Oracle provide persistent links to the latest updates of each Java version as documented at
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=397248601136938&id=1414485.1 - though you need to create/log in to an Oracle Support account. *Otherwise you can only access the last "public" update of each Java version, e.g. 1.6_u45 (Mar 2013; Latest update is u65, Oct 2013)*
Once you know the persistent link, you should be able to resolve it to the real download;
The following works for me, though I don't yet know if the "aru" reference changes.
ME=<myOracleID>
PW=<myOraclePW>
PATCH_FILE=p13079846_17000_Linux-x86-64.zip
echo "Get real URL from the persistent link"
wget -o getrealurl.out --no-cookies --no-check-certificate --user=$ME \
--password=$PW --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" \
https://updates.oracle.com/Orion/Services/download/$PATCH_FILE?aru=16884382&\
patch_file=$PATCH_FILE
wait # wget appears to go into background, so "wait" waits
# until all background processes complete
REALURL=`grep "^--" getrealurl.out |tail -1 |sed -e 's/.*http/http/'`
wget -O $PATCH_FILE $REALURL
#These last steps must be done quickly, as the REALURL seems to have a short-lived
#cookie on it and I've had no success with --keep-session-cookies etc.
As already posted here:
https://stackoverflow.com/a/41718895/4370196
Update for JDK 8 Update 121
Since Oracle inserted some md5hash in their download links, one cannot automatically assemble a download link for command line.
So I tinkered some nasty bash command line to get the latest jdk download link, download it and directly install via rpm.
For all who are interested:
wget -q http://www.oracle.com/technetwork/java/javase/downloads/index.html -O ./index.html && grep -Eoi ']+>' index.html | grep -Eoi '/technetwork/java/javase/downloads/jdk8-downloads-[0-9]+.html' | (head -n 1) | awk '{print "http://www.oracle.com"$1}' | xargs wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" -O index.html -q && grep -Eoi '"filepath":"[^"]+jdk-8u[0-9]+-linux-x64.rpm"' index.html | grep -Eoi 'http:[^"]+' | xargs wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" -q -O ./jdk8.rpm && sudo rpm -i ./jdk8.rpm
The bold part should be replaced by the package of your liking.
I solve this (for Debian based Linux distros) by making packages using java-package a few times (for various architectures), then distributing them internally.
The big plus side is that this method always works; no matter how crazy Oracle's web pages become. Oracle can no longer break my build!
The downside is that it's a bit more work to set up initially.
Download the tar.gz files manually in a browser (thus "accepting" their terms)
Run make-jpkg jdk-7u51-linux-x64.tar.gz. This creates oracle-java8-jdk_8_amd64.deb
Distribute it within your organization
For distribution over the Internet, I suggest using a password protected apt repository or provide raw packages using symmetric encryption:
passphrase="Hard to crack string. Use /dev/urandom for inspiration."
gpg --batch --symmetric --force-mdc --passphrase-fd 0 \
oracle-java8-jdk_8_amd64.deb <<< "$passphrase"
Of course providing (unencrypted) .deb packages on the internet is probably a violation of your license agreement with Oracle, which states:
... Oracle grants you a ... license ... to reproduce and use internally the Software complete and unmodified for the sole purpose of running Programs"
On the receiving end, if you have a password protected apt repo, all you need to do is apt-get install it. If you have raw packages, download, decrypt and dpkg -i them. Works like a charm!
wget This Worked for me JDK8
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2F%www.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm"
The accepted answer was not working for me, as of 2017-04-25. However, the simple solution was using the -b flag instead of the --header option.
For example, to get jdk-1.8_131:
version='8u131'; wget -H -O jdk-$version-linux-x64.tar.gz --no-check-certificate --no-cookies -b "oraclelicense=a" http://download.oracle.com/otn-pub/java/jdk/$version-b11/jdk-$version-linux-x64.tar.gz
That will execute in the background, writing output to wget-log.
Try
wget --no-cookies --header "Cookie: s_nr=1359635827494; s_cc=true; gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk6downloads-1902814.html; s_sq=%5B%5BB%5D%5D; gpv_p24=no%20value" http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64-rpm.bin --no-check-certificate -O ./jdk-6u45-linux-x64-rpm.bin
if you are like me trying to get Oracle JDK 6.
source: Oracle JVM download using curl/wget
I've made a jdk-download script (specific for the tar.gz) for my gentoo boxes. Doesn't need to be updated like other similar scripts, trying to "brute-force" download the latest build for whatever version you want.
USAGE
jdk-download< <version> <platform> [<build>]
* <version> - Something like "8u40"
* <platform> - Usually i586 or x64
* <build> - The internal build number used by oracle, to avoid guessing and trying to download starting from 99 to 1 (build 0, really?!!)
Blog post
Source on bitbucket
oracle-java-download is a project on GitHub that allows you to create download links for JDK 8 and JDK 9 which you can use for further processing e.g in automated build or deployment processes.
It requires Linux, Docker and a JDK >= 8 to run.
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm?AuthParam=1516282527_40effcfefd78d78bce12c0a4030a1b05"
Context
I recently faced the same problem and although the comments on this page and some
others provided helpful hints - I thought it would be good to document the steps I took to fix the problem for folks who may be in need of further help.
System Details
I am following the PNDA set up on AWS by following the step by step pnda installation guide at:
https://github.com/pndaproject/pnda-guide/blob/develop/provisioning/aws/PREPARE.md
I am using ubuntu 14.04 [free tier eligible] on AWS cloud, and am running the code from 64 bit windows8.1 laptop. I am using PUTTY to connect to the server instance. I git cloned the pnda code from https://github.com/pndaproject/pnda to the ubuntu instance.
Important Note
Please note that if you plan to use Ubuntu instance on AWS make sure it's 14.04 only. If you use version 16, it does not work. I learnt it the hard way!
Resolution Steps
As those who have gone as far as to have encountered the error being discussed here would know - the mirror creation file involves the following steps -
1) Run the script create_mirror.sh [ sudo su -s ./create_mirror.sh ] to run the full mirror creation process
2) This script in turn calls various other scripts - one of them being create_mirror_misc.sh; this script refers to pnda-static-file-dependencies.txt which has a list of files to be downloaded.
3) On the very first line of the pnda-static-file-dependencies.txt is a reference to download the jdk-8u131-linux-x64.tar.gz file from http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz oraclelicense=accept-securebackup-cookie; It is at this point that my script was failing with the message Failed to download http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz after 3 retries
4) I browsed to the page http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz and found the following error message displayed **In order to download products from Oracle Technology Network you must agree to the OTN license terms**
5) To resolve this problem I made the following change to the pnda-static-file-dependencies.txt; I added --no-check-certificate --no-cookies to bypass the license term agreement condition
6) So the revised code looks like - http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz --no-check-certificate --no-cookies oraclelicense=accept-securebackup-cookie
I hope this is helpful.
you should try:
wget \
--no-cookies \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/jdk-8u172-linux-x64.tar.gz \
-O java.tar.gz
download jdk 8u221
$ wget -c --content-disposition "https://javadl.oracle.com/webapps/download/AutoDL?BundleId=239835_230deb18db3e4014bb8e3e8324f81b43"
$ old=$(ls -hat | grep jre | head -n1)
$ mv $old $(echo $old | awk -F"?" '{print $1}')
my blog 044-wget下载jdk8u221
Here's how to get the command yourself.
This works for any version:
Access packages page here: https://www.oracle.com/java/technologies/javase-jdk11-downloads.html
Click the download link for your desired package
Check the box indicating that you have "reviewed and accept..."
Right-click & Copy the link address from the button
Paste into a text editor and then copy everything AFTER 'nexturl=', beginning with 'https://'
Update the download URL in this command and you should be good to go:
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn/java/jdk/11.0.6+8/90eb79fb590d45c8971362673c5ab495/jdk-11.0.6_linux-x64_bin.tar.gz
To further explain the wget, the --no-check-certificate should be clear enough, but the header content (for any call) is discoverable by using the Developer Tools Network Tab in your browser. The developer tools are powerful and are well worth the time to learn.
Enjoy.
This problem will be solved from Oracle JDK 17 onwards -
https://www.oracle.com/java/technologies/jdk-script-friendly-urls/
The latest version of Oracle JDK 17 can be downloaded from a command line, or automatically in scripts and dockerfiles by using download URLs which will deliver the then current update release.
One can use -
wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
format to get the latest 17 release
This happens because when you click the "Accept" button on the download page in your browser, the webpage saves a cookie that it uses to check your agreement before letting you download the file. The problem occurs when trying to download from the command line using wget and it's because there's no cookie information sent with the wget request for downloading the file so from the file server's perspective, you're a completely new user who hasn't accepted the license agreement.
One solution is to send cookie information using the --header option of the wget utility (as shown above in other answers). Ideally if some content is protected, you'd use the various session management options available with wget. For this particular problem however, it's solved (currently) by sending the Cookie header with the download request.
#eric answer did the trick for me, you need to accept terms in the command you are setting
i.e
"Cookie: oraclelicense=accept-securebackup-cookie"
so your final command looks thus
wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
You can decide to update the version by changing 8u131 to 8uXXX. so long it is available in the repo.
sudo wget --no-check-certificate --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.rpm"
Why not click to download from your browser then copy & paste the exact link where it was downloaded, for example:
wget http://download.oracle.com/otn-pub/java/jdk/7u40-b43/jdk-7u40-linux-x64.tar.gz?AuthParam=1380225131_dd70d2038c57a4729d8c0226684xxxx
You can find out the link by looking at the network tab of your browser after accepting terms in oracle and clicking to download. F12 in Chrome. Firebug in Firefox.
I am trying to call a java program in php to use it with web interface.
Java program is dependent on an external lib: commons-cli-1.2.jar
So basically I need to export it before calling the java program; but if I export it first as:
shell_exec('export CLASSPATH=$CLASSPATH:~/lib/commons-cli-1.2.jar');
then call the java program as:
shell_exec('java ComputePagerank -i $para_i -d $para_d -e $para_e -o $para_o');
I think it creates different shells for each call; then the export does not have any effect on java program. Or am I wrong?
Otherwise, it should output a file in the server. But simply it does not. So, what is wrong? Any idea?
edit: However can it be because some parameters such as para_i stands for an input file name, so that i have to specify full path for that? Because I just assume if the input file is in the same working directory, there won't be any problem, will it?
edit-2: it outputs properly when i use command line;)
you're right, each shell_exec creates a separate shell.
env CLASSPATH=whatever java -switches
I would use
shell_exec('java -cp $CLASSPATH:/home/yourname/dir/lib/commons-cli-1.2.jar ComputePagerank -i $para_i -d $para_d -e $para_e -o $para_o > message');
and (this is important) replace the tilde(~) with the actual path to your directory (/home/yourname say). The ~ is expanded by the shell and is dependent on which shell you''re using.
Try Creating a simple shell script with the commands that you want to execute. You may pass arguments to a shell script so that is not a problem either.
for example
echo "Running Script..."
java -cp $CLASSPATH:~/lib/commons-cli-1.2.jar ComputePagerank -i $1 -d $2 -e $3 -o $4 > message
etc.
Then try calling it from the command line first with some parameters. Did it output? Then try calling it from the php script. Did it output? If it did not then you may need to check permissions. I had a simiolar experience some time ago with a Java program that simply did not have permission to write a file.
You should be able to call it like this.
shell_exec('java -cp $CLASSPATH:~/lib/commons-cli-1.2.jar ComputePagerank -i $para_i -d $para_d -e $para_e -o $para_o > message');
Another option is to issue the 2 commands seperately, but to the same shell, like this:
shell_exec('export CLASSPATH=$CLASSPATH:~/lib/commons-cli-1.2.jar; java ComputePagerank -i $para_i -d $para_d -e $para_e -o $para_o > message');
edit:
some shells don't let you call export while you're setting up the variable. so this may be safer than the second option above:
shell_exec('CLASSPATH=$CLASSPATH:~/lib/commons-cli-1.2.jar; export CLASSPATH; java ComputePagerank -i $para_i -d $para_d -e $para_e -o $para_o > message');
another edit:
If none of the above work then you're going to have to do some more trouble shooting. Does your java program work from the command prompt?
java -cp $CLASSPATH:/home/user/lib/commons-cli-1.2.jar ComputePagerank -i param1 -d param2 -e param3 -o param4 > message