How to Install Oracle Java 8 on Ubuntu 16.10 via PPA
If you want to run a program written in Java, then you will need to install JRE (Java Runtime Environment); if you want to begin developing Java programs, then you also need to install JDK (Java Development Kit) which includes JRE, no matter what operating system you use. This tutorial will be showing you how to install Oracle Java 8 on Ubuntu 16.10 via PPA. PPA method is easier and faster than manual installation.
Once you finish this tutorial, you Ubuntu 16.10 system will have the following:
- Java JDK (Java Development Kit)
- JRE (Java Runtime Environment)
- Java browser plugin
So without further ado, let’s get started.
Install Oracle Java 8 on Ubuntu 16.10 via PPA
Fire up a terminal window (
CTRL+ALT+T) and run the following 3 commands to add the PPA, update local package index and install the Java 8 installer.
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install java-common oracle-java8-installer
Please note that this PPA installs an Oracle Java 8 installer which then download the actual Java files from Oracle website and install it on your system.
During the installation process, you will need to accept the Oracle binary code license terms.
Once the installation is finished, you can check Java version with the following command:
And check Java compiler with:
Setting Environment Variables
The following 4 Java related environment variables should be automatically set once you installed Oracle Java 8 with PPA.
You can see their values using
echo command like below.
If for any reason these environment variable isn’t set, then install
sudo apt-get install oracle-java8-set-default
This package will install a
jdk.sh file under
/etc/profile.d/ directory. If you take a look at this file, then you can see it’s used to set the above environment variables.
export J2SDKDIR=/usr/lib/jvm/java-8-oracle export J2REDIR=/usr/lib/jvm/java-8-oracle/jre export PATH=$PATH:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin export JAVA_HOME=/usr/lib/jvm/java-8-oracle export DERBY_HOME=/usr/lib/jvm/java-8-oracle/db
We need to reload
/etc/profile with the following command to let these environment variables take effect.
I hope this tutorial helped you install Oracle Java 8 on Ubuntu 16.10. Subscribe to our free newsletter to get latest Linux tutorials. You can also follow us on Google+, Twitter or like our Facebook page.