Child pages
  • Oracle JDK

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Table of Contents

Introduction

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.

Installation

Before installing be sure on what's your plan and your 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.

Then check your Java Environment. A jinfo should exist populated with your appropriate commands, tools or libraries including a unique priority number.

The Install your new JVM through the update-alternatives mechanism.

Anchor
SettingJavaEnvironmentVariables
SettingJavaEnvironmentVariables
Setting Java Environment Variables

To automatically set up the Java 8 environment variables, you can install the following package:

...

Code Block
languagebash
themeEmacs
update-initramfs -u

Troubleshooting

Firewall/cacher

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.

Architecture

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.

Plugin

In some cases, the presence of IcedTea Java Browser plugin (OpenJRE implementation) will prevent Oracle Java plugin from working or even being installed.

...

In the jinfo file we introduced in the Java Environment Tutorial there are some plugin support described:

...

In the update-alternatives we Install only the Firefox Java plugin :

Code Block
languagetext
#sudo update-alternatives --install /usr/lib/xulrunner-addons/plugins/libjavaplugin.so xulrunner-1.9-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so 1073;
sudo update-alternatives --install /usr/lib/firefox-addons/plugins/firefox-javaplugin.so firefox-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so 1073;
#sudo update-alternatives --install /usr/lib/iceape/plugins/iceape-javaplugin.so iceape-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so 1073;
#sudo update-alternatives --install /usr/lib/iceweasel/plugins/iceweasel-javaplugin.so iceweasel-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so 1073;
#sudo update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so 1073;
#sudo update-alternatives --install /usr/lib/midbrowser/plugins/midbrowser-javaplugin.so midbrowser-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so 1073;
#sudo update-alternatives --install /usr/lib/xulrunner-addons/plugins/libjavaplugin.so xulrunner-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so 1073;

Once you have installed the Firefox Java plugin support you should see the following link:

...

In the update-alternatives we Remove only the Firefox Java plugin :

Code Block
languagetext
#sudo update-alternatives --remove xulrunner-1.9-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so;
sudo update-alternatives --remove firefox-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so;
#sudo update-alternatives --remove iceape-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so;
#sudo update-alternatives --remove iceweasel-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so;
#sudo update-alternatives --remove mozilla-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so;
#sudo update-alternatives --remove midbrowser-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so;
#sudo update-alternatives --remove xulrunner-javaplugin.so /usr/lib/jvm/default-java/jre/lib/i386/libnpjp2.so;

Once you have removed the Firefox Java plugin support no more symlink should exist:

...