Install Java on Ubuntu 16.04 (Just 1 Minute Tutorial for Beginners)

Install Java on Ubuntu 16.04 (Just 1 Minute Tutorial for Beginners)

Introduction

What is Java?

Java is one of the essential programming language which has been widely used in all application developments. It has a lot of variations and usage in network and web app developments.

Here:

In this tutorial, we will see how to install Java on Ubuntu 16.04 server using terminal. Many programmers are using Ubuntu Operating System due to its long term support and consistency.

Developing your web app or running on application requires java most of the time. So, it is better to install Java when you create new server with your cloud service provider.

Without further Ado, lets dive into the installationmpart

Requirements

  1. Ubuntu 16.04 server from any cloud service provider or installed on your own machine
  2. You will need a server configured according to the Ubuntu Initial Server setup guide.

Install Java on Ubuntu

Installing Java is easy with Ubuntu from its repository. You can install Open JDK version 8 from Ubuntu repository using the Ubuntu install Open JDK  commands. Open JDK version 8 stable and is recommended by all the leading experts.

So, here in this tutorial, we will install Open JDK 8 on our server. First, Update the package index using the below command.

First, we have to install Java Run Time Environment. To do that, use the command below.

The JRE is only enough to run the Applications which requires Java. If you want to use JDK instead, you can install it.

The Java Development Kit installs the Java Run Time environment by default when you install JDK.

But:

JDK requires more space to install, however it is an advantage for you. To install JDK, run the below command.

Install Oracle JDK in Ubuntu

You have to do one more thing. That is downloading the PPA from Oracle and add it to the Ubuntu Repository.

Use the add-apt-repository command to accomplish the task.

This will download the Personal Package Archive(PPA) from Oracle and add it to the Ubuntu Repository. Then, update the Ubuntu repository with the below command.

There are a lot of versions being released by Oracle with Major updates. You can install them any of them by specifying the version in the command.

Installing Oracle 8 JDK

Most of the people are installing this version of Oracle on their server due to its support. Oracle JDK 8 is the stable version. To install that, just use the below command.

At the same time, if you want to install any other available version, just mentioned the version in the command.

If i want to install Java 9, then i will use the below command.

Switching Between Multiple Versions of Java

You can use multiple versions of the Java programming language in the same server.

But:

You have to switch between the Version which you have installed. To do that, use the update alternatives command.

The command will show you the following output.

If you want to use the same version that you are using now, just press enter or type the number from the list to use that targeted version.

Setup the Java Installation Location

You have to setup the Java Home Environment variable to indicate the installation location of the Java Run time environment.

To find the Java installation location, use the command below.

From there copy the path, then open a file using nano editor as mentioned below.

In that file, just paste the below command which contains the installation location of Java.

Make sure, you paste the exact location where Java is installed.

Then, save and exit the file. To make the changes to work, just reload the file.

Now, check the environmental variable setup using the below command.

The command will show you the path which you have entered in the nano editor.

Conclusion

If you can’t install Java on Ubuntu server, command below or just ask for help from the support team by contacting us.

Make sure, subscribe for Server Clear upcoming tutorials. We will notify you of webinar and new tutorial release.

Here is the install java Fedora Tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *