
Hacking Oracle Web Installer
Unless Slow Fetch-Download Installs is Preferred
For anyone that has installed Oracle Java™ on Ubuntu, you know the process is notoriously slow. What you might not know is that the official Oracle Debian package doesn’t actually contain the software, they are just wrapper scripts that download the package from a third-party partner mirror. Occasionally these mirrors are not operational or are notoriously slow.
Wouldn’t it be nice to have Java tarball available on your Intranet?
This article is about automating this process, so you can take the nightmare, and yes I mean nightmare, out of installing Oracle Java™ on your systems.
Configure A Web Server
You want to create a location where you can store the tarball, such as /var/www/java
, and then copy the target tarball to the location.
mkdir -p /var/www/java
cp /tmp/jdk-8u161-linux-x64.tar.gz /var/www/java
For this example, we’ll use nginx. You want to serve using a virtualhost of download.oracle.com
, as this is what the client tools will use. This way anything that looks for that hostname, will be directed to your designated location.
server {
listen 80;
server_name download.oracle.com; access_log /var/log/nginx/java-access.log;
error_log /var/log/nginx/java-error.log; location / {
rewrite /.*/(.*) /$1 last;
root /var/www/java;
autoindex on;
}
}
The magic that makes this work is a small rewrite rules that smashes whatever path Oracle uses (and they do change their scheme frequently) to just simple /
.
You may need this in your /etc/hosts
to get this to work:
172.16.0.50 download.oracle.com
Configure The Client
The only thing needed on the client is /etc/hosts
entry to point to our web server that hosts the Java tarball.
172.16.0.50 download.oracle.com
You can test out the server with with any path, and the results will be the same:
Install Oracle Java
Now you can embark on the journey of installing Oracle Java™ using their official installer program. To get their installer, simply do the following:
After this is been completed, you are ready to install the installer package:
apt-get install oracle-java8-installer
Maintaining Versions
This works really well with the current Oracle Java™ JDK 8 on Ubuntu 14.04 Trusty Tahr. As you are downloading the tarball outside of Oracle’s Partner network, you’ll have to routinely fetch new versions to keep up with the Oracle Webupd8 Team’s installer.
The alternative to constantly maintaining tarball versions, would be to version lock the install:
apt-get install oracle-java8-installer=8u161-1~webupd8~0
The challenge with this is that Oracle Webupd8 Team’s Repository may not have earlier versions available, so have to do some fancy mirror management with a tool like Aptly to keep such locked versions in sync.