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.
You can do this for;
Final Update
JDK
JRE
Old Update
I found two repository but I do not recommend
OpenJDK builds (all archs)
OpenJDK 8 backport for trusty
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
To automatically set up the Java 8 environment variables
Check it
So you have to wait to use OpenJDK8
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 usetrusty-backports
then it may be installable from there at some point. Read about the process for requesting backports in Ubuntu here.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:
For installing 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:
Now, to copy & paste the location of Open JDK 8 to match the command below:
Here's what I use to set up Oracle Java 7 and Java 8 [note: not OpenJDK] from scratch on Ubuntu 14.04 LTS:
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.
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:
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!(Please feel free to add other providers)
See other answers for details.
Personally I would recommend upgrading Ubuntu to 18.04 LTS, 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
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:
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:
Install the packages:
Run dpkg for each of the .deb files you downloaded. It may produce errors due to missing dependencies:
To fix missing dependencies:
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 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:and here is my
uname -a
output:and here is my
lsb_release -a
output: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!
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:
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)
Run the shell one-liner Nix tells you to at the end of the installation:
$ . ~/.nix-profile/etc/profile.d/nix.sh
Install the OpenJDK Nix package:
$ nix-env -i openjdk
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).I'm getting OpenJDK 8 from the official Debian repositories, rather than some random PPA. Here's how I did it:
Make
/etc/apt/sources.list.d/debian-jessie-backports.list
: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
:Then finally do the install: