Hamsa K
Editor
5 min read | 4 years ago

How to Install JAVA on Ubuntu 18 04 bionic

Install Java13 on ubuntu 18.04

Oracle Java JDK (Java Development Kit) is a development environment for developing applications and tools based on Java. It is used for testing applications, and program development alike, using the Java programming language.there is another option as open Java JDK / JRE (an open-source alternative) using apt-get repository.

First we will check with openjdk with default packages

Step 1: Install openjdk

root@ubuntu18:~# apt update
root@ubuntu18:~ apt install default-jdk

Also Read -> How to Install Yarn in Ubuntu 18 04

Now you can check java version by below command.

root@ubuntu18:~# java -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Ubuntu-0ubuntu1.118.04)
OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Ubuntu-0ubuntu1.118.04, mixed mode, sharing)

We hope you are following "How to Install JAVA on Ubuntu 18 04 bionic" step by step carefully. The remaining steps will help you to finish the upgrade process..

Step 2: Install java using oracle jdk using PPA repo

Alternatively, it is possible to install Java on Ubuntu using the official Oracle JDK

Also Read -> How to install java 12 centos 7

To install Java 13 on Ubuntu 18.04 and you need to add the linux uprising java PPA repository as shown below.

root@ubuntu18:~# apt install software-properties-common
root@ubuntu18:~# add-apt-repository ppa:linuxuprising/java

now you can install java. Here i am installing java13 on ubuntu 18.04

root@ubuntu18:~# apt update
root@ubuntu18:~# apt install oracle-java13-installer

check java version

root@ubuntu18:~# java --version
java 13.0.2 2020-01-14
Java(TM) SE Runtime Environment (build 13.0.2+8)
Java HotSpot(TM) 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)

If you need to set Oracle Java 13 as the default Java version, install the following package if it was not installed.

root@ubuntu18:~# apt install oracle-java13-set-default

Step 3: Setup java environment variables

To set Java home environment variable, you first need to Java installation location by running following command 

root@ubuntu18:~# update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
  Selection    Path                                         Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      manual mode
* 2            /usr/lib/jvm/java-13-oracle/bin/java          1091      manual mode
Press <enter> to keep the current choice[*], or type selection number:

open the /etc/environment configuration file and set Java home environment variable like below.

root@ubuntu18:~# vi /etc/environment

Add below line to above file and save it

JAVA_HOME="/usr/lib/jvm/java-13-oracle"

To load the environments into the current session, run below command

Also Read -> How to Install Docker on Centos 7

root@ubuntu18:~# source /etc/environment

Finally check java home environment variable setting, run the command below

root@ubuntu18:~# echo $JAVA_HOME
/usr/lib/jvm/java-13-oracle

That's it. you have successfully installed Java 13 on ubuntu 18.04 server.

Also Read -> how to Install java 13 on centos 8



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy