×
Community Blog How to Install Java (JRE or JDK) on Ubuntu 16.04

How to Install Java (JRE or JDK) on Ubuntu 16.04

In this article, we will introduce some methods of using commands to install Java (JRE or JDK) on Ubuntu 16.04.

Normally Oracle Java is packed with both Java Runtime (JRE) and JDK. Here we would like first to introduce how to install Java 8 on Ubuntu 16.04, you can first add the PPA repository for Java.

sudo apt install -y software-properties-common
sudo add-apt-repository --yes ppa:webupd8team/java
sudo apt update

Install Java 8.

sudo apt -y install oracle-java8-installer

You can verify if Java has been installed successfully by running java -version command.

aliyun@jenkins:~$ java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

Set the default path for the JAVA_HOME by installing the following package.

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

You can now check if JAVA_HOME variable is set by running echo $JAVA_HOME. You may also need to log out and log back in to get the desired output.

aliyun@jenkins:~$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle

This method is from CI/CD with Jenkins - Part 1: Install Jenkins on Ubuntu.

Related Blog Posts

Installing Neo4j on Ubuntu 16.04

Neo4j is a rapidly growing Graph Database choice, as claimed by Neo4j Inc. In this tutorial, we'll show you how to install Neo4j on an Alibaba Cloud Elastic Compute Service (ECS) instance with Ubuntu 16.04.

Installing Java

To install Neo4j on Ubuntu, we must install Java first. Java might not be installed by default. We can verify it using this command.

bash
java -version

After running this command, if you get similar output like below, you need to install Java in the instance and if Java is already installed in your instance, you can skip this step.

bash
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-5-jre-headless
 * openjdk-8-jre-headless
 * gcj-4.8-jre-headless
 * gcj-4.9-jre-headless
 * openjdk-9-jre-headless
Ask your administrator to install one of them

To install Java in the instance, use the following command:

bash
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

In the last step, you'll be prompted to accept the agreement, so go ahead and comply with the terms to continue further.

Once these commands finish running, you should have Java installed in your machine, lets verify the same using the command below.

bash
java -version

Now you should have similar output in your terminal after running the command.

bash
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

After Install Java, we can now go ahead and install Neo4j on the instance.

How to Install Graylog on Ubuntu 16.04

Graylog is a powerful open-source log management platform that aggregates and extracts important data from server logs, which are often sent using the Syslog protocol. It also allows you to search and visualize the logs in a web interface.

Installing Default JRE/JDK

The easiest option for installing Java is using the version packaged with Ubuntu. Specifically, this will install OpenJDK 8, the latest and recommended version.

First, update the package index.

 sudo apt-get update

Next, install Java. Specifically, this command will install the Java Runtime Environment (JRE).

 sudo apt-get install default-jre

There is another default Java installation called the JDK (Java Development Kit). The JDK is usually only needed if you are going to compile Java programs or if the software that will use Java specifically requires it.

The JDK does contain the JRE, so there are no disadvantages if you install the JDK instead of the JRE, except for the larger file size.

You can install the JDK with the following command:

 Sudo apt-get install default-jdk
0 0 0
Share on

Alibaba Clouder

2,605 posts | 747 followers

You may also like

Comments