Ubuntu does not come with Java pre-installed. However, it is possible to install Java with the help of commands. This short guide explains how you can use commands on linux terminal to install JDK in Ubuntu. 

Java Programming Language

Popular programming language Java was created in 1995. It runs more than 3 billion devices worldwide. It is a general-purpose popular programming language with a variety of uses. For example, four of its most common uses are developing desktop applications, web applications, games and mobile applications. Moreover, it is used for big data processing, and embedded systems. 

There are many benefits of using Java. First of all, it can run on a lot of operating systems like Windows, Linux, Mac, Pi, and Raspberry. Secondly, a huge community uses it, so you can easily get support. Third, it is easy to learn. Fourth, it is secure. 

Learning java would get you attractive career opportunities. There is a huge demand for java programmers in the market. It is also an object-oriented language like C and C++. So, learning Java also makes learning C and C++ easy. 

How To Install JDK in Linux Ubuntu?

There are many methods of installing Java in Ubuntu. The apt-based installation path is most easy to follow. Especially, if you want to be able to run or compile java code easily and smoothly. JDK stands for Java Development Kit. It comes with everything that a user needs to use Java. 

It is a simple three-step process. Verify that you do not already have Java, update your package listing, install Java, and verify that the installation has been successful. Let us start. 

Step 1: Check If It is Already Installed or Not

You can skip this step, if Java is already installed. Enter the following command for it.  

$ sudo java -version

This command asks the system what version of Java is installed on your system. It would return an error if Java is not installed, and if it is installed it tells the version. However, it may ask for the root user password first. 

As you can see, it has returned an error. So, we have to install JDK now. It is not pre-installed. 

Step 2: Update Your Package Listing with Apt

It is essential to update your Ubuntu package list with the latest information. Enter the following command for it. 

$ sudo apt-get update

Step 3: Install JDK

Enter the following command to install JDK. 

$ sudo apt install default-jdk

Step 4: Verify The Installation

Now, we will again give the java -version command to ask the version of Java present in the  system. If installation has been successful, it will tell the version. 

Congratulations! You have installed JDK in Linux successfully. 


Apt install command is used to install JDK in Linux Ubuntu. Everything required to run and compile Java codes is there in JDK. Install it and use Java on Linux easily.