(2017-08-08: Question cleaned and summarized in a new answer)

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?

(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)


  • 1
    You need to compile it yourself. Here is how: github.com/hgomez/obuildfactory/wiki/… Change the filename to match version 8 ;-) – Rinzwind May 12 '14 at 11:08
  • 2
    Azul has started providing OpenJDK builds under the name "Zulu" which can be downloaded, unpacked and used automatically. (They earn their money from support). azulsystems.com/products/zulu/downloads – Thorbjørn Ravn Andersen Jul 11 '15 at 9:34
  • 1
    Notibly, the same ppa that apt-fast for trusty is hosted on, ppa:saiarcot895/myppa, has a version of openjdk-8 that works. shrug – ThorSummoner Jan 20 '16 at 6:45
  • As time marches on, it seems that the simplest solution is simply to opgrade 16.04 LTS when available. – Thorbjørn Ravn Andersen Feb 9 '16 at 11:01
  • And openjdk-9-jdk is in 16.04 LTS :) (probably just a placeholder fo rnow) – Thorbjørn Ravn Andersen Mar 7 '16 at 12:09

12 Answers 12

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

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

  • 8
    @JohnMerlino my guess would be that the PPA allows for automatic updates when new versions are released. – Thorbjørn Ravn Andersen Jun 22 '14 at 21:24
  • 7
    openjdk-8 is now in Utopic. bugs.launchpad.net/ubuntu/+source/openjdk-8/+bug/1341628 has been raised to backport to 14.04 as it is LTS: – Thorbjørn Ravn Andersen Aug 4 '14 at 12:06
  • 50
    Why the new edit? It seems to still not be in the 14.04 repo yet and sudo apt-get install openjdk-8-jdk doesn't work at least for me. – xji Dec 4 '15 at 20:14
  • 14
    As of 2016-01-11 the non-official Ubuntu PPA's are still needed, as OpenJDK 8 has not yet landed in backports. I do not consider this to be an answer to my question even though it appears others do. – Thorbjørn Ravn Andersen Jan 12 '16 at 8:51
  • 6
    This answer is highly misleading due to being incomplete, it says it doesn't recommend the PPA mentioned but won't work without it. – Reinier Post Sep 22 '16 at 9:41
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
  • 7
    This repository is dated; as of today the latest openjdk 1.8 release is 66. The version available in this repository is 45. – mattm Nov 10 '15 at 13:58
  • Failed to fetch ppa.launchpad.net/openjdk-r/ppa/ubuntu/pool/main/o/openjdk-8/… 502 apt-cacher: libcurl error: Failure when receiving data from the peer – Rajesh Hatwar Oct 28 '16 at 6:30
  • 1
    These are the correct minimal steps. 4 and 5 are optional and possibly not required. – Air Dec 23 '16 at 18:37
  • Not working for Ubuntu 14.04 E: Package 'openjdk-8-jdk' has no installation candidate – Naive Jul 26 '17 at 12:57
  • This worked for me when upgrading Jenkins (newer version required Java8, my system only had Java7 installed). Of note, the fourth line was critical to get Jenkins to behave properly; until running it, I kept getting Jenkins requires Java8 or later, but you are running 1.7.0_121-b00 from /usr/lib/jvm/java-7-openjdk-amd64/jre. Have an upvote... I'd give you more if I could. – Doktor J Oct 12 '17 at 20:26

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.

  • 4
    I tried to answer your question "how and when" with the constraints that you seem to want: must be from official repositories, must be OpenJDK, and must be the 14.04 LTS release. – Mike Miller May 13 '14 at 12:54
  • 28
    Its Feb 2016, and java 8 is still not available on Ubuntu 14.04 LTS. This is disappointing. – Bhavin Doshi Feb 11 '16 at 6:10
  • 2
    It's April 2016, still no java 8... – Stephan Henningsen Apr 1 '16 at 9:45
  • 3
    Ubuntu 16.04 is coming out in April 2016, it will have OpenJDK 8. – Mike Miller Apr 2 '16 at 20:21
  • 7
    It's Sep 2016, and Ubuntu 14.04 LTS will still be supported until 2019... and lots of places will take a long time to adopt 16.04 because of larger-scale changes (e.g. systemd), so it's still disappointing java 8 is not easy to install via apt on 14.04 :( – geerlingguy Sep 3 '16 at 21:34

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
  • 3
    I still only see JDKs 6 and 7, no openjdk-8-jdk on my Linux 14.04, after sudo apt-get update. Did you add some special repository? I've got trusty-backports enabled. – akauppi Apr 19 '15 at 19:25
  • 2
    I think you're running 14.10 or 15.04, are you not? – akauppi Apr 19 '15 at 19:30
  • 1
    I cannot reproduce on 14.04 LTS. Please confirm this is the version. – Thorbjørn Ravn Andersen Apr 20 '15 at 7:59
  • 1
    @akauppi you are right!! I'm running 14.10. Sorry for the inconvenience, should I remove my answer? – caraca Apr 20 '15 at 14:51
  • 1
    I wouldn't wish it removed - for some, using 14.10 instead of 14.04 might be a perfectly good alternative. – akauppi Apr 21 '15 at 8:06

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.

  • 1
    Looks good. But it is missing the part where you gain root access. Still nice answer. – MadMike Jan 16 '15 at 7:37
  • 1
    Right; I use this with Vagrant, which sets up the vagrant user with passwordless sudo. – Cagatay Jan 17 '15 at 13:21
  • 5
    This is Oracle Java, not OpenJDK Java which was what the question was about. Also note that the echo lines circument the license acceptance question from the installer. – Thorbjørn Ravn Andersen Apr 20 '15 at 7:59
  • 3
    @ThorbjørnRavnAndersen Yes, I did notice the question was about OpenJDK; I specifically said that my method is for installing Oracle Java. You may argue that this is not related, but I think there's value in noting an alternative that still gets you a runtime that can run Java 7/8 on 14.04 LTS. "Circumvention" of license acceptance question is an interesting word choice; I would say one should read the Oracle license before running the script, which automates the acceptance during the installation. – Cagatay Apr 21 '15 at 17:10
  • 3
    Thanks @Cagatay !! this answer was very useful for me, I was looking Java 8 installation using Vagrant. – Sotsir Sep 15 '15 at 21:49
up vote 12 down vote accepted

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 many 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 onwards)
  • 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. Note that Oracle Java appears to be only for paying customers in the foreseable future (around Java 11).
  • Download OpenJDK 8 using a third party PPA.
  • Download a Azul certified build of OpenJDK 8 from http://www.azul.com/downloads/zulu/zulu-linux/ (DEB)
  • Compile the source and install it yourself.

See other answers for details.

Note that Personal Package Archives (PPA) are usually made by individuals on a voluntary basis. The contents may be out of date or go away without warning.

Personally I would recommend upgrading Ubuntu to 18.04 LTS, or if not possible download a Azul build.


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

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    

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!

  • I would recommend using Azul Zulu. azul.com/downloads/zulu – Thorbjørn Ravn Andersen May 10 '17 at 8:19
  • I also had to run the following to get it working : sudo update-java-alternatives --jre --set java-1.8.0-openjdk-amd64 and sudo update-java-alternatives --jre-headless --set java-1.8.0-openjdk-amd64 – champost Jul 26 '17 at 11:07

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).

  • 1
    Out of curiosity - why would you want an additional package manger besides apt-get? – Thorbjørn Ravn Andersen Oct 10 '15 at 13:00
  • 2
    @ThorbjørnRavnAndersen - the specific reason is to quickly get OpenJDK 8 with minimal pain, and the general reason is that Nix is a revolutionary improvement over apt-get and other older package managers. – Yawar Oct 10 '15 at 15:51
  • I am asking in the general case - not for OpenJDK specifically. There must be very heavy reasons for introducing a new package manager to outweigh not using the existing ecosystem, which I have a hard time seeing. – Thorbjørn Ravn Andersen Oct 10 '15 at 21:31
  • 1
    @ThorbjørnRavnAndersen - there are very good reasons to recommend Nix in the general case. As I mentioned, it is a revolutionary improvement. On the scale of git over svn. Check out infoq.com/articles/configuration-management-with-nix for more. – Yawar Oct 11 '15 at 5:01

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
  • This answer does not work for me. openjdk-8-jdk wants openjdk-8-jre that wants libjpeg62-turbo. According to apt this latter is "not installable" or more verbosely "is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source" -- thus not from the repositories I have. The chasing becomes too wide to be wise – XavierStuvw Jan 6 '17 at 15:12

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

  • 1
    Building is one thing. What about the TCK? – Thorbjørn Ravn Andersen Nov 24 '14 at 23:32
  • 1
    @ThorbjørnRavnAndersen I have no idea. For an individual end-user, self building is already useful IMHO. For actually preparing a thoroughly tested package, it's probably another story... I'm afraid I know nothing more than you. I just looked around and found openjdk.java.net/groups/conformance/JckAccess, had you seen that? – vorburger Nov 25 '14 at 13:43

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"
  • 2
    The first line is not needed. The next 4 lines are equivalent to add-apt-repository ppa:openjdk-r/ppa. This answer is also a duplicate of older ones. – Paul Stelian Apr 18 '16 at 9:44
  • 1
    In summary (as of 2017-05-02), this is what works for me. sudo add-apt-repository -y ppa:openjdk-r/ppa; sudo apt-get update; sudo apt-get install -y openjdk-8-jdk – Tzunghsing David Wong May 3 '17 at 0:31

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.