How to Install Oracle Java 13 on Ubuntu 18.04/16.04 LTS

In this article, We are going to perform How to Download and Install Oracle JAVA 13 on Ubuntu 18.04/16.04 LTS Manually or any other cloud platform like Amazon EC2, Azure VM, Google Cloud Compute,etc. with preinstalled Ubuntu OS.

Introduction

Java is a set of software and specifications developed at Sun Microsystems. There are two tyes of Java Platforms are JDK (Java Development Kit) and JRE (Java Runtime Environment). Both are helpful for deploying applications on servers and debugging, JVM monitoring,developing.

Prerequisites

  • Ubuntu Server 16.04/18.04 LTS
  • SSH access with sudo privileges

To check Ubuntu version:

$ uname -a

OR

$ cat /etc/os-release

Output:

NAME="Ubuntu"

VERSION="18.04.3 LTS (Bionic Beaver)"

ID=ubuntu

ID_LIKE=debian

PRETTY_NAME="Ubuntu 18.04.3 LTS"

VERSION_ID="18.04"

HOME_URL="https://www.ubuntu.com/"

SUPPORT_URL="https://help.ubuntu.com/"

BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"

PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"

VERSION_CODENAME=bionic

UBUNTU_CODENAME=bionic

Follow the below steps to Install Oracle Java 12 on Ubuntu Manually using command line.

Step 1: Download Oracle Java 13

Generally Oracle will not allow to download directly without accepting their licenses. We have to create one account in Oracle java website by your personal or official mail. After accepting license download the application from browser to local machine.

This link takes you to the Oracle home website Oracel Java SRE.

Once you opened above link goto “Java SE Development Kit 13.0.2” section, click on download “jdk-13.0.2_linux-x64_bin.tar.gz”  and “ Accept Oracle License Agreement” and setup for Ubuntu.

download oracle java 13

After downloading into local machine, using SCP/SFTP/FTP transfer the file from local machine to Ubuntu server

Step 2: Copy downloaded Setup and Extract

Create a directory /opt/jdk

$ sudo mkdir -p /opt/jdk

Copy the tar  file from the directory copied from local machine to server to /opt/jdk folder and execute below command:

$ sudo cp -rf /home/fosstechnix/jdk-13.0.2_linux-x64_bin.tar.gz /opt/jdk

Navigate to /opt/jdk directory

$ cd /opt/jdk/

Extract the Oracle Java 13 setup

$ sudo tar -zxf jdk-13.0.2_linux-x64_bin.tar.gz

Now unarchived the file and check the content by long-list:

# ls

Step 3: Install Oracle Java 13 on Ubuntu with Alternatives

Use update-alternatives command to configure java on your system

$ sudo update-alternatives --install /usr/bin/java java /opt/jdk/jdk-13.0.2/bin/java 1

After executing above command it shows below output:

Output:

 update-alternatives: using /opt/jdk/jdk-13.0.2/bin/java to provide /usr/bin/java (java) in auto mode

Now set default java 13

Note : Its not particularly o/p if you have installed open jdk before

Step 4: Verify Update Alternatives

Enter below command to see java alternatives

$ sudo update-alternatives --display java

Output:

java - manual mode
link best version is /usr/lib/jvm/java-13-oracle/bin/java
link currently points to /usr/lib/jvm/java-13-oracle/bin/java
link java is /usr/bin/java
slave java.1.gz is /usr/share/man/man1/java.1.gz
/opt/jdk/jdk-13.0.2/bin/java - priority 1
/usr/lib/jvm/java-13-oracle/bin/java - priority 1091
slave java.1.gz: /usr/lib/jvm/java-13-oracle/man/man1/java.1.gz

Set the default Oracle Java 13 using below command

$ sudo update-alternatives --config java

It prompts for selecting by 0,1,2..so choose accordingly, if you have already installed any oracle java.

Output:

There are 3 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-13-oracle/bin/java 1091 auto mode
1 /opt/jdk/jdk-12.0.2/bin/java 2 manual mode
2 /opt/jdk/jdk-13.0.2/bin/java 1 manual mode
* 3 /usr/lib/jvm/java-13-oracle/bin/java 1091 manual mode

Press <enter> to keep the current choice[*], or type selection number: 2

SET Default Java Compiler

Run the commands below to make Java 13 to be the default Java compiler for your Ubuntu System

sudo update-alternatives --install /usr/bin/jar jar /opt/jdk/jdk-13.0.2/bin/jar 1

sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk-13.0.2/bin/javac 1

sudo update-alternatives --set jar /opt/jdk/jdk-13.0.2/bin/jar

sudo update-alternatives --set javac /opt/jdk/jdk-13.0.2/bin/javac

Now We have performed install oracle  Java 13 on Ubuntu.

Step 5: Setting the JAVA 13 Environment Variables

To set JAVA environment variables, create a new file under /etc/profile.d directory.

$ sudo nano /etc/profile.d/jdk13.sh

Add below lines

export J2SDKDIR=/opt/jdk/jdk-13.0.2

export J2REDIR=/opt/jdk/jdk-13.0.2

export PATH=$PATH:/opt/jdk/jdk-13.0.2/bin:/opt/jdk/jdk-13.0.2/db/bin

export JAVA_HOME=/opt/jdk/jdk-13.0.2

export DERBY_HOME=/usr/lib/jdk-13.0.2/db

To Load environment variables, Enter below command,

$ source /etc/profile.d/jdk13.sh

Step 6: Verify Java Version

To check the java version:

$ java -version

Output:

java version "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) you seeing output like above then we have  successfully set up the Java 13 on Ubuntu.

Conclusion

In this article, We have covered install oracle java 13 on Ubuntu, downloaded Oracle Java 13 from official site, installed using command line, configured JAVA_HOME and JRE_HOME, verified installed version.

Related Articles:

How to Download and Install Oracle Java 12 on Ubuntu 18.04/16.04 LTS

How to Download and Install Oracle JAVA 11 on Ubuntu 18.04/16.04 LTS

How to Download and Install Oracle Java 8 on CentOS 7 

How to Download and Install Oracle JAVA 8 on Ubuntu 18.04/16.04 LTS

Sivasai Sagar

I am working as DevOps Engineer and having 5 years of Experience. Likes to share knowledge.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap