Table of Contents
Manual installation of Oracle Java (which is preferred to Open Java, which often doesn't work right) is a bit tedious: one needs to find and download the latest release and manually set up all the path variables.
The PPA from webupd8 developer team simplifies our task and provides us with an installer which does all this for us and enables auto-updates.
Before installing be sure on what's your plan and your 1 - Java Environment.
Run the following commands in order to install or update the Oracle Java. The idea is applicable to others JVM.
The installer takes a while since it needs to download the latest Java installer from the Oracle site.
The Install your new JVM through the update-alternatives mechanism.
Setting Java Environment Variables
To automatically set up the Java 8 environment variables, you can install the following package:
Below /etc/profile.d there are two files jdk.sh and jdk.csh who contain the environment variables definitions.
Here is the content of jdk.sh:
Here is the content of jdk.csh:
The oracle-java8-set-default package install only those two files.
The system will ensure that one those files will be runned when you open a session.
However the Java Environment variables collapse with the /usr/bin and /etc/alternatives system.
if we run the java command the PATH is resolved against /usr/bin. The default jdk.sh or jdk.csh add paths to solve the java commands, tools or libraries while it is already resolved though the standard update-alternative mechanism.
Beyond that it is pretty common to use the JAVA_HOME, the OpenJDK could need it as well. Not sure who is using the J2SDKDIR and J2REDIR environment variables but we keep it for integrity.
Further more Derby is delivered with the Oracle JDK but not with the OpenJDK. It sounds to us that gathering the Java environment variables in a single place is a good practice.
Here is a patched jdk.sh and jdsk.csh we use who improve the PATH strategy, we favored the /usr/bin and /etc/alternatives style and narrow the PATH strategy. Basically we remove the extra paths and kept the derby path.
Here is the content of our patched jdk.sh:
Here is the content of our patched jdk.csh:
Close and re-open a session and check your environment with a printenv command.
Not sure if we need to run this command, however for historical reasons we keep it.
The installer fetches the latest Java binary via wget. Most of the time, the download fails because either the firewall blocks it or because the cacher doesn't allow it. Since Java updates are not very frequent, we can turn off the firewall while installing, but the cacher can at least be configured for a permanent bypass. Create /etc/apt/apt.conf.d/03java-bypass with the following contents:
This will ensure that downloads from download.oracle.com initiated by pre/post-install scripts do not go through the cacher. The ideal solution would be to make them cached but that needs a regex hack for apt-cacher-ng (to stop it from rejecting this site as a cacheable source) which I was not able to develop yet.
If your host architecture differs from LTSP chroot, you won't be able to install Java this way. Chrooting will make the chroot report the host's architecture to the installer, which causes it to download the wrong binary. Generally, chroots should be kept the same architecture as host, but if they must be different, one can still install Java this way if live-boot from the correct architecture media is done and chroot is entered from it.
In some cases, the presence of IcedTea Java Browser plugin (OpenJRE implementation) will prevent Oracle Java plugin from working or even being installed.
It is advised to remove all icedtea packages either prior to Oracle Java installation or after it.
In the latter case, reinstallation of Oracle Java might be required to install the plugin properly.
Note: Oracle Java will not work in Google Chrome (since Google changed the plugin implementation system from previous standard) until Oracle issues an updated plugin.
As we see in the the Java Environment Tutorial the jinfo file is able to register the plugin support. However we do not use this mechanism.
This tutorial only use the Oracle Firefox Java support while Chrome and Chromium do not any more support.
Rather than using the jinfo file to register the plugin support we use the symobic link technics. Do you not forget to update it when upgrading.
Then test your Firefox configuration with