Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to install Oracle Java 8 on Ubuntu

📅 2014-Mar-25 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

Installing this new version of Java on Ubuntu is easy because there is a PPA for it:

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer

To set up the environment variables for Java 8:

$ sudo apt-get install oracle-java8-set-default

Check the version of the Java compiler and runtime:

$ java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

$ javac -version
javac 1.8.0

When Eclipse runs with this new Java version, it may produce an error saying Could not load SWT library. To fix this:

$ ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/

Tried with: Oracle Java 8, Eclipse 3.7.2 and Ubuntu 12.04