How to install OpenJDK 7 on Ubuntu Xenial Xerus 16.04

Hey guys!
Now that Xenial Xerus has released, many Ubuntu users would have already upgraded to the LTS release. But what many might not notice, is that the upgrade removes OpenJDK 7 from your system as well as the repositories, making it impossible to install the Java 7 JDK from the xenial universe.

Reason for removal

Since Xenial is an LTS (Long Term Support) release, Canonical has to ensure that the software packaged inside it is in active use and supported by the developers. Oracle decided to mark Java 7 End Of Life and so - to maintain support - Canonical removed it from the repositories along with Java 6 in favour of Java 8 and 9.

Reason for reinstallation

One main use case for Java 7 is the Android build environment. While AOSP has initiated support for Java 8, many ROM sources are still lagging behind (they have experimental support for 8).

Reinstalling OpenJDK 7

Thankfully, a member of the Ubuntu development team, Matthias Klose maintains a repository for openjdk packages (Thank you, Matthias!). So, to install OpenJDK 7, add the PPA by opening a terminal and typing the following:
sudo add-apt-repository ppa:openjdk-r/ppa
Then, update the software lists by typing:
sudo apt-get update
Finally, install the needed Java 7 package by typing (for the JDK and JRE):
sudo apt-get install openjdk-7-jdk
Or (For the JRE only):
sudo apt-get install openjdk-7-jre
Then, set the default used version of Java by issuing:
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javap
sudo update-alternatives --config javadoc
sudo update-alternatives --config javah
and choosing the Java 7 versions of he given executables
Cheers!
-Technohacker

Comments

Popular Posts