TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Linux

Install Oracle JDK on Ubuntu Linux

Ubuntu

Overview

In this tutorial, we will learn steps involved to download and install Oracle JDK on Ubuntu Linux machine. JDK install would be the first step to setup automation environment. Many servers and tools require JDK to be installed on the machine.

So, Let’s get started!

First things first, check if any JDK is installed on the machine before proceeding any further. Launch Terminal, and issue the java version command. We notice that OpenJDK is installed on the machine.

The main difference between OpenJDK and Oracle JDK is the license. Note that, in this post, we will install Oracle JDK.

java OpenJDK version

Remove OpenJDK

Issue the following command to remove the prior JDK install.

$ suo apt-get purge openjdk*

 

purge openJDK Linux

Click on Y  to any user prompts during the uninstall process.

Verify that the OpenJDK is removed from the machine.

No Java Installed

Download

Navigate to Oracle official website to download Oracle JDK.

https://www.oracle.com/in/java/technologies/javase-downloads.html

Choose Linux64 Compressed Archive tar file. JDK ships only for 64-bit architecture.

JDK Download Save File

 

Make sure your machine OS type is 64-bit architecture.

 

OS Type Ubuntu

Accept License

Its important to know that Oracle JDK license terms has changed since 2019. Please review the license terms carefully before downloading and using the product.

 

Oracle JDK License

Install

Locate the downloaded tar file on the computer.

Java JDK Download Path

Extract file contents

Extract the contents of the file. Issue the following tar command in the Terminal.

$ sudo tar -xvf <path to JDK tar file>

 

sudo tar command Linux

JDK Contents

JDK Extracted Contents

Consider a favorable location for the JDK and move the contents to that location. For example to

/opt  or /usr/lib

Set JAVA_HOME variable

Edi the /etc/profile using your favorite text editor. For example,

$ sudo gedit /etc/profile

Set JAVA_HOME environment variable. Add the bin directory to the PATH environment variable. Add the below lines to the file and save the file. Make sure you modify the directory path of the JDK as per your install.

JAVA_HOME=/opt/jdk

PATH=$PATH:$JAVA_HOME/bin

export JAVA_HOME

export PATH

 

Etc Profile Linux

 

Run the following command in the Terminal.

. /etc/profile

Verify Install

Verify the JDK install using the java version command. Since, we have appended the JDK bin directory to PATH, we can issue the command anywhere in the directory tree on the machine.

$ java -version

 

Oracle JDK Install Verify

 

Echo the Java variables to verify them and to check if the bin directory is appended to the PATH.

$ echo $JAVA_HOME

$ echo $PATH

That’s it. We are done with the JDK install on Ubuntu Linux.

Related:

Install Eclipse IDE on Ubuntu:

https://www.testingdocs.com/install-eclipse-on-ubuntu-linux/

Related Posts

Android Studio Setup Wizard

Linux /

Customization of Android Development Environment

Download Android Studio

Linux /

Download Android Studio Package on Linux

gedit Text Editor Ubuntu

Linux /

gedit Text Editor in Linux

Download Ubuntu Desktop

Linux /

Create Ubuntu Bootable USB Pendrive on Windows

Linux /

Linux Files

‹ Linux Commands to Monitor System Runtime information› Linux Filesystem

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version