In this tutorial, I will show you how to install Oracle Java 8 on Ubuntu based Linux distributions, including Ubuntu 16.04/14.04, Linux Mint, Elementary OS, from PPA (Personal Package Archive). The following will be installed on your system once you finish this tutorial.
Programs written in Java such as phpStorm can run on any operating system that has Java installed.
Run the following 3 commands one by one in your terminal to add the PPA and install Oracle Java8.
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install java-common oracle-java8-installer
The 3rd command will install the Oracle Java8 installer and itself will download Oracle Java 8 binary and then install it on your system. During the installation phase, you need to accept the Oracle binary code license terms.
Once the installation is complete, we can check Java version.
Check Java compiler version
Run the following command to set environment variable.
sudo apt-get install oracle-java8-set-default
Once installed, there will be two new files under /etc/profile.d/ directory: jdk.csh and jdk.sh. These two files are shell scripts that contains commands to set 5 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 to let these environment variables to take effect.
Now you can check these 5 environment variables like below:
As you can see, it’s easy to install Oracle Java 8 on Ubuntu, Linux Mint and Elementary OS once you read this tutorial. Comments, questions or suggestions are always welcome. If you found this post useful, ? please share it with your friends on social media! Stay tuned for more Linux tutorials.