How to install Java 8 (and Java 9) on Ubuntu

I recently decided to go back to Java, especially because of the features provided in version 8. Here’s how I did it (tldr in bottom).

First things first, we need a repository to pull the packages from, so we add webupd8team’s java PPA repository with:

sudo add-apt-repository ppa:webupd8team/java

Running this gave me a warning that stated there was no java-files in the repository, links to the installationguides from webupd8team and a important notice telling me to continue using Java 8 (which I’m trying to install) instead of Java 9 (which is in early access release) since it could contain issues and might not include the latest security patches. I proceeded (hit “Enter”).

We then run:

sudo apt-get update

to be able to list the packages from the newly added repository. This lets us run:

sudo apt-get install oracle-java8-installer

that installs java 8. If you search the repositorys packages you see that you can install the Java 9 installer, but you should probably just use Java 8 until Java 9 has its real release. Don’t despair if you get an error because of unconfigured packages. Solve the issue and the installer continues where it left off.

You can verify the install using:

java -version

which should output something similar to java version “1.8.xx”.

If you looked through the packages from webupd8 ppa repo, you also probably noticed they prodvided a package that sets the environment variables.

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

And now you should be ready to go on your next adventure with Java 8 in your toolbelt.

Tl;Dr

Add repo: sudo add-apt-repository ppa:webupd8team/java
Update: sudo apt-get update
Install: sudo apt-get install oracle-java8-installer
Set default (opt): sudo apt-get install oracle-java8-set-default

References:

http://tecadmin.net/install-oracle-java-8-jdk-8-ubuntu-via-ppa/

Leave a comment

Your email address will not be published. Required fields are marked *