How to Install OpenJDK 8 in Ubuntu 14.04 & 12.04 LTS

Last updated: January 13, 2015

OpenJDK Java 8

OpenJDK Java 8 has been made into official Ubuntu repositories for 14.10 Utopic and higher. For Ubuntu 14.04, Ubuntu 12.04, and Linux Mint 17 users here’s how to install it from PPA.

OpenJDK 8 was released in March 2014. It’s available in Ubuntu Software Center for Ubuntu 14.10 and Ubuntu 15.04. Someone has reported in launchpad asking for packaging openjdk-8 in Ubuntu 14.04, but no luck so far.

As a workaround, you can install OpenJDK 8 from a PPA repository:

1. Open terminal from the Dash or by pressing Ctrl+Alt+T. When it opens, run the command below to add PPA:

sudo add-apt-repository ppa:openjdk-r/ppa

Type in user password when it asks and hit Enter to continue.

2. After that, update system package cache and install OpenJDK 8:

sudo apt-get update 

sudo apt-get install openjdk-8-jdk

3. If you have more than one Java versions installed on your system. Run below command set the default Java:

sudo update-alternatives --config java

Type in a number to select a Java version.

And set default Java Compiler by running:

sudo update-alternatives --config javac

4. Finally check out current Java version by running:

java -version

It outputs something like this:

openjdk version "1.8.0_01-internal"
OpenJDK Runtime Environment (build 1.8.0_01-internal-b04)
OpenJDK 64-Bit Server VM (build 25.40-b08, mixed mode)

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via ubuntuhandbook1@gmail.com Buy me a coffee: https://ko-fi.com/ubuntuhandbook1 |

14 responses to How to Install OpenJDK 8 in Ubuntu 14.04 & 12.04 LTS

  1. Hi Ji m.

    The problem is that this JDK 8 is rather old: 1.8.0_01-internal. For instance, on my MacBook Pro I have JDK 1.8.0_40. Unfortunately it seems that there’s nothing as recent for Ubuntu.

    • Ofc., the (Launchpad) ppa is unavailable for 15.10 wily & while there *is* a package included with the distro – WHO KNOWS whether it’s backport, or WHAT will be the deal with it, meh. It’s (quite) stressful, the way Flash, Java & a whole-bunch of other stuff is (not) handled – as, per, usual, blah. ;$

  2. Even in ubuntu 14.10, if we use openjdk-8, how to use it in firefox as icedtea plugin is not available for java 8. If available or if there is any workaround, let us know.

  3. @Fabrizio – You may have noticed this already, but currently (April 13th, 2015) the version you get if you follow the instructions above, is: openjdk version “1.8.0_40-internal”

  4. Rather than using update-alternatives which can only update a single binary at a time, use update-java-alternatives which handles all relevant java binaries simultaneously. This ensures that not only java and javac will point to java 8, but all the associated java binaries will also point to java 8 (jhat, jstack, etc, etc)

    See: http://askubuntu.com/a/141798

  5. Note, if you’re using Ubuntu prior to 13.10 you’ll need to get python-software-properties installed before it will recognize the add-apt-repository command:
    sudo apt-get install python-software-properties

  6. I can’t use javac command.

  7. Worked perfectly for me. Ubuntu 14.04 64 bit.

  8. It’s telling me I have unmet dependencies, and you didn’t tell us how to fix that.

  9. Thanks, it was a big help for me.

  10. Thanks worked perfectly on mint 17.2 64 based on Ubuntu 15.10

  11. Using update-java-alternatives on Ubuntu 14.04 LTS produced a series of error messages. Then it reverted Java to 1.7 (Version 7, some update number) = icedtea. The Command Code used in the article itself did not have that effect, and the change to Java 1.8 (Version 8, Update 45) stuck through rebooting. So, the Comment had code which at least in my system, does not work properly.

    One hangup might be the Firefox Mozilla Java Plugin, which does not have a version 8 in the Ubuntu Repositories at this time. Trying to update every binary at the same time can run into these sorts of issues. Best to stick with the stepwise approach and test at each stage of updating when using alternatives or ppa sources.