OpenJDK 8 which provides the JRE and JDK to work with Java 8 is available from Ubuntu repositories.
- Exit all Java applications, like Eclipse for example.
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
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