How to install OpenJDK 8 on 14.04 LTS?

You can do this for;

Final Update

JDK

sudo apt-get install openjdk-8-jdk

JRE

sudo apt-get install openjdk-8-jre

Old Update

I found two repository but I do not recommend

  • OpenJDK builds (all archs)

      ppa:openjdk-r/ppa
    
  • OpenJDK 8 backport for trusty

      ppa:jochenkemnade/openjdk-8
    

Original Message

If you really want to use OpenJDK, you have to compile from source. There is not still any PPA for OpenJDK.

It has been requested at https://bugs.launchpad.net/ubuntu/+bug/1297065

I recommend you to use Webup8 Oracle Java8 Installer

Note: WebUpd8 team's PPA has been discontinued with effective from April 16, 2019. Thus this PPA doesn't have any Java files. More information can be found on PPA's page on Launchpad. Hence the below method no longer works and exists because of historical reasons.

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

To automatically set up the Java 8 environment variables

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

Check it

java -version

So you have to wait to use OpenJDK8


sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
sudo update-alternatives --config java
sudo update-alternatives --config javac

OpenJDK 8 was released in March 2014. As of the time of this question, there are no OpenJDK 8 packages in the official Ubuntu repositories for any Ubuntu release. They "will be available soon", as the JDK 8 project page says, for some definition of soon.

First, the OpenJDK 8 packages will land in the Ubuntu development release. This may happen during the 14.10 development cycle, but there is no set schedule as far as I know. Some preview packages have been built and are available for testing, see the announcement on the debian-java and Ubuntu openjdk mailing lists. At some point these packages will be uploaded to the Debian and Ubuntu development repositories.

Once OpenJDK 8 is in the Ubuntu development version, then it may be possible to request that it be backported to 14.04. Note that it will never be available in the primary trusty repository, but if you use trusty-backports then it may be installable from there at some point. Read about the process for requesting backports in Ubuntu here.