How To Install Java 10 On Ubuntu

How To Install Java 10 On Ubuntu

It explains how to install Java 10 distributed by Oracle on Ubuntu 18.04 (Bionic Beaver). The steps should be similar to install other versions of Java and Ubuntu.

October 13, 2018

In this post, we will discuss all the steps required to install Java 10 distributed by Oracle on Ubuntu 18.04 (Bionic Beaver). The steps should be similar to other releases of Java, Ubuntu and other flavors of Linux.

Step 1 Download JDK

Open the browser and search for Download JDK 10 or click here to open the download page. It will show the JDK download page as shown in Fig. 1.

JDK 10 Download Page

Fig. 1

Now click the download link having tar.gz extension as highlighted in Fig 1. A confirmation dialog will be displayed to accept the license agreement and start the download as shown in Fig.2 and Fig. 3.

Accept License Agreement

Fig. 2

Confirm Download

Fig. 3

We can also download the JDK on terminal using below mentioned command:

>sudo wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_linux-x64_bin.tar.gz

Step 2 Install Java

Open the terminal and make directory /usr/java to keep java installations. We can install multiple versions of Java in this directory. Now copy the downloaded file to this location and extract it as shown below:

>sudo mkdir /usr/java
>cd /usr/java
>sudo cp  jdk-10.0.2_linux-x64_bin.tar.gz
>sudo tar -xzvf jdk-10.0.2_linux-x64_bin.tar.gz

The above steps will install JDK to the path /usr/java/jdk-10.0.2

Step 3 Set Environment Variables

>sudo nano /etc/profile

Scroll down by pressing Page Down button and add at the end of this file:

JAVA_HOME=/usr/java/jdk-10.0.2
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH

Now press Ctrl + O and press Enter to write our change. Press Ctrl + X to exit the nano editor. The nano editor should look like the one shown in Fig. 4.

Environment Variables

Fig. 4

Step 4 Configure Java Commands

Now we need to configure Java commands to newly installed JDK. We can check the installed Java before and after executing these commands as shown below:

>java -version
>sudo update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-10.0.2/bin/java" 1
>sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-10.0.2/bin/javac" 1
>sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/java/jdk-10.0.2/bin/javaws" 1
>java -version

The output of these commands is displayed on Fig. 5.

Java Commands

Fig. 5

Summary

This is how we can install Java distribution from Oracle on Ubuntu 18.04 (Bionic Beaver).

Write a Comment
Click the captcha image to get new code.
Discussion Forum by DISQUS