Update: Oracle Java 8 is now stable. Below you'll find instructions on how to install it in Ubuntu / Linux Mint via a PPA repository. The PPA supports JDK8 for both 32bit and 64bit as well as ARM (ARM v6/v7 Hard Float ABI - there's no JDK 8 ARM Soft Float ABI archive available for download on Oracle's website).
It's also important to note that the Oracle Java 8 installer is considered in alpha and is offered without any guarantees! Use it at your own risk. If you ISP or router blocks the ports used by the Oracle Java 8 download servers, the installation may fail.
Debian users will find installation instructions in the following article: How To Install Oracle Java 8 In Debian Via Repository [JDK8]
Install Oracle Java 8 (JDK8 and JRE8) in Ubuntu or Linux Mint
The installer provides Oracle Java 8 (which includes Java JDK, JRE and the Java browser plugin). However, you can't only install Oracle JRE - the PPA only provides the full Oracle JDK8 package.
Our PPA supports Ubuntu 16.10, 16.04, 15.10, 14.04 and 12.04 as well as Linux Mint 18, 17.x and 13. Add the PPA and install Oracle Java 8 (the package provides both JDK8 and JRE8) using the following commands:
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer
Update October 20, 2016:
Previously, this package would increment the Java priority to make it default. The oracle-java8-installer package now sets the Java priority to 1081, and that may or may not set it as default, depending on other Java packages you may have installed (for instance, if Java 7 is also installed, Java 8 becomes default, but if Java 9 is installed, Java 8 doesn't become default).
To make Java 8 default, you must install the "oracle-java8-set-default" package (which configures the Java environment variables and sets it as default), which I added as a "Recommended" package to "oracle-java8-installer".
In Ubuntu, recommended packages are automatically installed, so "oracle-java8-set-default" should be installed when installing "oracle-java8-installer". In Linux Mint on the other hand, recommended packages are not installed by default, so you must install this package manually if you want to set Oracle Java 8 as default.
So, if you want to set Oracle Java 8 as default, no matter what other Java versions are installed, make sure that you install the oracle-java8-set-default package (which, again, should be automatically installed with the main Oracle Java Installer package in Ubuntu, but not in Linux Mint):
sudo apt-get install oracle-java8-set-default
If you don't want to make Oracle Java 8 default (it might still be set as default, depending on what other Java versions you may have installed), install the oracle-java8-installer with "--no-install-recommends":
sudo apt-get install --no-install-recommends oracle-java8-installer
Note: removing the oracle-java8-set-default package does not undo all the changes (I have yet to find a way to do this properly). If you don't want to set it as default, remove both oracle-java8-installer and oracle-java8-set-default packages, and then install oracle-java8-installer with "--no-install-recommends" (like mentioned above).
Tip: if you're behind a firewall / router that blocks some of the redirects required to download the Oracle Java archive, you can download the JDK tar.gz archive manually and place it under /var/cache/oracle-jdk8-installer - then, installing the "oracle-java8-installer" package will use the local archive instead of trying it to download it itself.
After installing Oracle Java and the "oracle-java8-set-default" package, running "java -version" in a terminal should output something like this:
Or, "javac -version":
andrei@andrei-desktop:~$ java -version java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
And so on.
andrei@andrei-desktop:~$ javac -version javac 1.8.0_111
Automated installation (auto accept license)
The installer requires you to accept the Oracle license before the installation begins. This is only required once. If for some reason you need the installation to be automated, you can run the following command to automatically accept the Oracle license:
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
Switching between Oracle Java 9 and Java 7
You can have both Java 8 and Java 9 installed in the same time, but only one can be set as default.
To set which is default, simply install its "set-default" package: oracle-java8-set-default for Oracle Java 8, or oracle-java9-set-default for Oracle Java 9.