How to Download and Install Oracle Java by a Script?
The Popular Webupd8 Team Ppa Is Not Being Updated. It Has Still Obsolete Versions Like 8U45. I Manually Downloaded Jdk from Oracle Site and Replaced It. Is...
The popular WebUpd8 Team PPA is not being updated.
It has still obsolete versions like 8u45.
I manually downloaded JDK from Oracle site and replaced it.
Is there a way to automatically check Oracle java latest version and download it, if it has been updated?
I see the main problem is to download it. I looked in oracle-java8-installer scripts and see some weird links they download it from.
The tarball can't be downloaded directly from Oracle site without accepting a license. The installer checked that too. But I do not quite get how to accept the license from command line.
This script could be added to cron.
Just in case the PPA is never updated, or if there are delays like this time.
3 Answers
The script works in conjunction with the WebUpd8 PPA. Therefore install Java by the PPA first.
If there is a new version in the PPA, then this is installed via the package manager. In the meantime, the script can install a newer version, it there is a new version on the Oracle website.
Must Read
A few considerations
Download a version via wget, eg:
wget --no-cookies --header \
"Cookie: oraclelicense=accept-securebackup-cookie" \
$URL
Get the URL with (for linux-x64 and tar.gz)
URL=$(curl -s | \
awk "/downloads\['/ && ! /demos/ && /\['files'\]/ && /linux-x64/ && /\.tar\.gz/" | \
grep -o 'http.*\.tar\.gz')
All in one
for Oracle Java 8 via the URL
wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" \
$(curl -s | \
awk "/downloads\['/ && ! /demos/ && /\['files'\]/ && /linux-x64/ && /\.tar\.gz/" | \
grep -o 'http.*\.tar\.gz'\
)
Explanation
/downloads\['/– We need thedownloadsarea/\['files'\]/– We need thefilesarea/linux-x64/– The target architectureThat you could adapt.
/\.tar\.gz/– The file formatThat you could adapt.
If you do that, don't forget the
tar.gzingrep -o 'http.*\.tar\.gz'! /demos/– No demos