Site icon installvirtual

How to install OpenJDK 8 on Ubuntu 16.04 (Xenial)

Install OpenJDK 8 on Ubuntu 16.04 (Xenial)

In this tutorial, I will show you how to install OpenJDK 8 on Ubuntu 16.04 (Xenial). The Java Development Kit (JDK) is a software development environment used for developing Java applications and applets. It includes the Java Runtime Environment (JRE), an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc) and other tools needed in Java development.

Pre-requisites

Read Also: Install postgreSQL 11 on Debian 10 (Buster)

Install Java 8

Here we will use apt to install Java 8 on Ubuntu 16.04 (Xenial)

$ apt install openjdk-8-jdk

Check java Version

Now after installing open JDK check the version using the following command

$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.16.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

Read Also: How to install Java 11 on CentOS 7

Set Java Home Environment

We need to set Java home Environment Variable in order to use java with some applications. Let’s get started.

$ update-alternatives --config java

There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Nothing to configure.

Option 1: Set Environment Variable

$ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

Option 2: Adding in .bash_profile

In this option, I will add an entry in .bash_profile.

$ vim ~/.bash_profile

add the following and save and quit.

$ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

Now source the file.

$ source ~/.bash_profile

Now check the Java Home

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

If you have any issue using this tutorial please feel free to comment below.

Summary
Article Name
How to install OpenJDK 8 on Ubuntu 16.04 (Xenial)
Description
Install OpenJDK 8 on Ubuntu 16.04 (Xenial). In this tutorial, I will show you how to install OpenJDK 8 on Ubuntu 16.04 (Xenial). The Java Development Kit (JDK) is a software development environment used for developing Java applications and applets. It includes the Java Runtime Environment (JRE),
Author
Publisher Name
installvirtual
Exit mobile version