324

Java 8 is now available according to http://openjdk.java.net/projects/jdk8/, but http://openjdk.java.net/install/ does not yet mention how to install OpenJDK 8 (not Oracle Java) on Ubuntu 14.04 Long Term Support. (For 14.10 and later just run apt-get install openjdk-8-jdk)

How and when can this be done?

(2017-08-08: The very short answer is: OpenJDK 8 as of 2017-08-08 is not officially available from the official repositories as an APT package for Ubuntu 14.04. See full summary in this answer - updated 2021-06-29)

Note: For now we will use Oracle Java - the optimal solution for me is, however, OpenJDK from the Ubuntu repositories, until Oracle Java is available directly and effortless from the Ubuntu repositories.


12 Answers12

292

Editors note: This answer is outdated as the PPA’s listed are not available anymore.


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

muhasturk
  • 3,486
  • 3
  • 14
  • 9
201
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
wjandrea
  • 14,504
63

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.

37

Note – This will only work with 14.10 or later:

1 year late, but as today it works as expected with apt-get.

For installing JDK:

$ sudo apt-get install openjdk-8-jdk

For installing JRE:

$ sudo apt-get install openjdk-8-jre

How to set the default JDK

Fastest way

Run $ sudo update-alternatives --config java and enter the number for which JDK to use of your choice.

Second way

List the available JDK's:

$ update-java-alternatives -l
java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64
java-1.8.0-openjdk-amd64 1069 /usr/lib/jvm/java-1.8.0-openjdk-amd64

Now, to copy & paste the location of Open JDK 8 to match the command below:

$ sudo update-java-alternatives -s /usr/lib/jvm/java-1.8.0-openjdk-amd64
caraca
  • 487
23

Here's what I use to set up Oracle Java 7 and Java 8 [note: not OpenJDK] from scratch on Ubuntu 14.04 LTS:

apt-get -y -q update
apt-get -y -q upgrade
apt-get -y -q install software-properties-common htop
add-apt-repository ppa:webupd8team/java
apt-get -y -q update
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
apt-get -y -q install oracle-java8-installer
apt-get -y -q install oracle-java7-installer
update-java-alternatives -s java-8-oracle

This is unattended and is suitable for inclusion in a Vagrant provision block; I have a gist with more details: https://gist.github.com/tinkerware/cf0c47bb69bf42c2d740

EDIT: This will automatically accept Oracle's license for the JDK; make sure you are okay with that first before running it.

Cagatay
  • 339
19

As of 2017-08-08 I found that this question and its answers had become a bit overwhelming to dig through to understand the issue, so I have summarized the findings in this answer.

The very short answer is that OpenJDK 8 as of 2017-08-08 is not officially available for Ubuntu 14.04.

There are however several options available:

  • Upgrade to a newer version of Ubuntu. OpenJDK 8 is available from 14.10 and onwards. (OpenJDK 9 from 16.04 LTS onwards, OpenJDK 11 from 18.04 LTS onward). Unless you are under extended support this is the best approach as of 2021.
  • Download a Azul certified build of OpenJDK 8 from http://www.azul.com/downloads/zulu/zulu-linux/ - they have both 64-bit and 32-bit versions.
  • Download and install Oracle Java (not OpenJDK) from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html manually as a tar.gz file which just needs to be unpacked and have the license accepted before the bin directory can be added to your $PATH variable. You might also choose to use a third party PPA. IMPORTANT: The license was changed in 2019 to be more restrictive and you may need to be a paying customer to use Oracle Java in production!
  • Download OpenJDK 8 using a third party PPA. This is an increasingly bad idea as they tend to grow stale or disappear as they are usually made by individuals on a voluntary basis.
  • Compile the source and install it yourself.

(Please feel free to add other providers)

See other answers for details.

Personally I would recommend upgrading Ubuntu to 18.04 LTS or newer, or if not possible download a Azul build. AdoptOpenJDK/Eclipse Adoptium is only an option from 16.04 onwards on x64.


Note: If you still need OpenJDK 8 backported to 14.04, vote for this bug by logging in and clicking "Does it affect you" at the top: https://bugs.launchpad.net/ubuntu/+source/openjdk-8/+bug/1368094

5

Note Since 22 April 2016 the packages for Vivid have been removed, alas. News item in packages.ubuntu.com: "Reflect xenial release, add yakkety, remove vivid". The workaround of this answer is clever but no longer applicable in the current situation. As of 6 Jan 2017 there's no backport for java 8 on trusty packages.ubuntu.com/trusty-backports/java yet. Please edit as changes apply.


See the answer from Android official site

https://source.android.com/source/initializing.html

There are no available supported OpenJDK 8 packages for Ubuntu 14.04. The Ubuntu 15.04 OpenJDK 8 packages have been used successfully with Ubuntu 14.04. Newer package versions (e.g. those for 15.10, 16.04) were found not to work on 14.04 using the instructions below.

Download the .deb packages for your architecture from http://packages.ubuntu.com/vivid/openjdk-8-jdk:
openjdk-8-jre-headless
openjdk-8-jre
openjdk-8-jdk

Remember, you may obtain the architecture for your machine with:

$ uname -m    

x86_64 represents a 64-bit (amd64) Linux kernel architecture and i386/i486/i586/i686 represents 32-bit (i386) system.

Optionally, confirm the checksums of the downloaded files using the information found on http://packages.ubuntu.com/vivid/openjdk-8-jdk.

For example with the sha256sum tool:

$ sha256sum {package file}    

Install the packages:

$ sudo apt-get update    

Run dpkg for each of the .deb files you downloaded. It may produce errors due to missing dependencies:

$ sudo dpkg -i {downloaded.deb file}    

To fix missing dependencies:

$ sudo apt-get -f install    
XavierStuvw
  • 1,591
Bin Chen
  • 171
4

I just did vote here and now we are 733 people that we do care about backporting openjdk-8 to ubuntu-14.04.

I found this PPA repository is quite uptodate

and hopefully promising!?

and it worked for me. I was successful to install openjdk-8-jdk on ubuntu-14.04 with following commands:

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

and here is my java -version output:

openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-1~14.04.york0-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

and here is my uname -a output:

Linux mars1 4.4.0-75-generic #96~14.04.1-Ubuntu SMP Thu Apr 20 11:06:30 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

and here is my lsb_release -a output:

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty

My virtual-host-server-provider is telling me they only provide support for Ubuntu-14.04 and I am guessing they want to keep going like this until 2019! so please let me know if you know any better way for having openjdk-8 on ubuntu-14.04?

Thanks!

SidMorad
  • 141
3

The Nix package manager also maintains binary packages of OpenJDK 8 for Ubuntu, meaning you can get a working Java 8 compiler in less than five minutes start to finish (with a fast internet connection, of course).

The steps are:

  1. Install the Nix package manager (https://www.domenkozar.com/2014/01/02/getting-started-with-nix-package-manager/): $ bash <(curl https://nixos.org/nix/install)

  2. Run the shell one-liner Nix tells you to at the end of the installation: $ . ~/.nix-profile/etc/profile.d/nix.sh

  3. Install the OpenJDK Nix package: $ nix-env -i openjdk

  4. Check javac: $ javac -version

That's it. Oh, and you'll want to make sure to put the one-liner from step 2 in your ~/.bashrc. That will tell Nix to link up your installed packages properly (since it keeps the actual files in non-standard directories).

Pablo Bianchi
  • 17,371
Yawar
  • 131
2

I'm getting OpenJDK 8 from the official Debian repositories, rather than some random PPA. Here's how I did it:

sudo apt-get install debian-keyring debian-archive-keyring

Make /etc/apt/sources.list.d/debian-jessie-backports.list:

deb http://<httpredir>.debian.org/debian/ jessie-backports main

where you change <httpredir> with the prefix for a near mirror (see https://www.debian.org/mirror/list)

Make /etc/apt/preferences.d/debian-jessie-backports:

Package: *
Pin: release o=Debian,a=jessie-backports
Pin-Priority: -200

Then finally do the install:

sudo apt-get update
sudo apt-get -t jessie-backports install openjdk-8-jdk
XavierStuvw
  • 1,591
1

It's actually also easy to build the Java 8 yourself directly from sources... Sounds scary? It really is surprisingly easy, and seriously literally takes about 15 minutes, using https://github.com/hgomez/obuildfactory/, as I've described on http://blog2.vorburger.ch/2014/06/build-your-own-jdk-at-home.html

vorburger
  • 704
1

Update on Mar 11 2016, run these as root:

apt-get update
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DA1A4A13543B466853BAF164EB9B1D8886F44E2A
touch /etc/apt/sources.list.d/openjdk.list
echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu trusty main " >>/etc/apt/sources.list.d/openjdk.list
echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu trusty main" >>/etc/apt/sources.list.d/openjdk.list
apt-get update
apt-get -y install openjdk-8-jdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
echo "$JAVA_HOME"