Updating java version to 8 on ubuntu

Java 8 is not available in the Ubuntu 12.04 repositories, but it is available from a Launchpad PPA.

You also cannot update a Java version to the next Java version, but you can install different Java versions side by side.

To install Java version 8 (OpenJDK 8 edition - not ORACLE Java 8) open a terminal and execute :

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk  

If you only want to install the Java Runtime Environment :

sudo apt-get install openjdk-8-jre  

Note 1 :

As you said "... without it being too complicated ...", I assumed that you installed Java 7 from the Ubuntu repositories, which contain OpenJDK and did not add the WebUpd8 PPA (ORACLE Java).

Note 2 :

As you said that you get the File "/usr/bin/add-apt-repository", line 37 print _("The %s named '%s' has no PPA named '%s'" ^ SyntaxError: invalid syntax error, have a look here.

Suggestion :

Keep both versions installed side by side, some other packages or programs might rely on Java 7.

However, when you don't want to have both versions and if don't need Java 7 anymore ... remove it.


As you did not specify whether you want to install OpenJDK or Oracle JDK, my answer covers Oracle JDK.

It is interesting to quote this text from here. What follows applies to JDK8 too and for all Ubuntu versions of yours or higher.

Oracle JDK7 itself is not hosted in the PPA because that's not allowed by the new Java license (which is also the reason why it has been removed from the official Ubuntu repositories); the package in the PPA automatically downloads Oracle Java JDK 7 from its official website and installs it on your Ubuntu / Linux Mint computer, just like the flashplugin-installer package does.

Note that JDK9 is expected to be released during this year, so do not try to use before that.

For this reason, this is is how to install (and not update) your Java 8 version:

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

Adding to the earlier answers...I had issues with my JAVA_HOME after the install from this ppa following this commands:

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

The 4th command doesn't work as expected. So in my case I have to manually run these commands:

sudo /etc/environment(add the below two lines and append to PATH if needed)
JAVA_HOME=/path-to-java-before-bin-directory
export JAVA_HOME

sudo source /etc/environment

and then it was working fine. verify it also:

root@ashu-700-430qe:/DataStax_POC# which java
/usr/bin/java
root@ashu-700-430qe:/DataStax_POC# java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
root@ashu-700-430qe:/DataStax_POC#

I referred this link. Hope this helps