Here’s a handy howto on installing Oracle JDK™ 1.8 on modern Debian and Ubuntu distros.
Oracle does not provide *.deb packages or an APT repository for easy installation of their JDK, and it is a bit of a hassle to setup all the bits and pieces just right so that the Oracle JDK tools are properly integrated into a Debian or Ubuntu installation.
By following the steps below you’ll be able to switch between any installed JDKs, including OpenJDK versions, with a single command.
1) Download Oracle JDK
You can download Oracle JDK from this
Look for the heading “Java SE Development Kit 8u102”, accept the license
agreement and download the tarball file
102 was the latest at the time of writing this blog, it might be different when
you read this. Remember to substitue the actual number everywhere.
Copy the file to the machine you want to install it on. We’ll assume the file is
2) Unpack the tarball
Next, unpack the tarball to the right place under
Unpacking will create the directory
3) Create the .jinfo file
The jinfo file is a kind of manifest of executables bundled in the JDK. Go ahead
and create the file
/usr/lib/jvm/.jdk1.8.0_102.jinfo with the contents
below. Note the leading “
.” in the filename, it is important!
4) Update Permissions
Let’s fix the permissions on all the files before moving on:
5) Update Alternatives
Next we’ll use the
update-alternatives command to register all the java
executables. These will create symlinks for each of them. To do this, run the
6) Update Java Alternatives
Finally, use the
update-java-alternatives command (which you may need to
install explicitly first) to point all the java executable symlinks to the
right version’s java executables.
You can check if it has been registered properly:
You’re All Set!
You should now be able to invoke any java executable:
If you have multiple versions installed, for example if you also have OpenJDK 8 also installed, you can switch between the two: