How to install OpenJDK 8

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.

  • If your Ubuntu version does not have Java 8, then add this PPA:
$ sudo add-apt-repository ppa:openjdk-r/ppa
$ sudo apt update
  • Install JRE and JDK of OpenJDK 8:
$ sudo apt-get update
$ sudo apt install openjdk-8-jre openjdk-8-jdk
  • Switch the default Java interpreter and compiler to v8:
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
  • There are a whole bunch of other Java tools (like jdb and javadoc) that can be switched to v8 versions, if necessary. You can list these using this command:
$ 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! 🙂

  • After making v8 the default, check if that worked. Here is the output on my computer:
$ 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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.