Code Yarns ‍👨‍💻

How to install OpenJDK 8

(First posted on: 2015-06-25 12:17:00+00:00)

OpenJDK 8 which provides the JRE and JDK to work with Java 8 is available from Ubuntu repositories or from a PPA depending on your Ubuntu version.

$ sudo add-apt-repository ppa:openjdk-r/ppa
$ sudo apt update
$ sudo apt-get update
$ sudo apt install openjdk-8-jre openjdk-8-jdk
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
$ sudo update-alternatives --get-selections | grep openjdk

An easier solution would be to just remove OpenJDK 7. But this can be difficult because other packages (like CUDA) rely on a particular version of OpenJDK. Furthermore, Ubuntu will indicate that if v7 is removed, it will install the older v6 in its place! 😊

$ java -version
openjdk version "1.8.0_01-internal"
OpenJDK Runtime Environment (build 1.8.0_01-internal-b04)
OpenJDK 64-Bit Server VM (build 25.40-b08, mixed 

$ javac -version
javac 1.8.0_01-internal

Tried with: Ubuntu 14.04