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:
java -version
And check Java compiler with:
javac -version
Setting Environment Variables
The following 4 Java related environment variables should be automatically set once you installed Oracle Java 8 with PPA.
- $J2SDKDIR
- $J2REDIR
- $JAVA_HOME
- $DERBY_HOME
You can see their values using echo
command like below.
echo $JAVA_HOME
Output:
/usr/lib/jvm/java-8-oracle
If for any reason these environment variable isn’t set, then install oracle-java8-set-default
package.
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.
cat /etc/profile.d/jdk.sh
Output:
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.
source /etc/profile
That’s it!
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.
sudo apt-get install java-common oracle-java8-installer
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package oracle-java8-installer
Ubuntu 16.10 reached end of life last year. It’s not supported any more.
You can upgrade to ubuntu 18.04 by following the instructions on this page: https://www.linuxbabe.com/ubuntu/upgrade-ubuntu-16-10-17-04-to-ubuntu-18-04