Select your language

You have multiple options for developing a Java application on Linux (Ubuntu or Debian).

Using the OpenJDK (Open Java Development Kit), which is an open and free implementation of the standard Java platform, or using the Oracle Java SE JDK from Oracle. Oracle JDK is recommended by the developer of the IDE (Google), especially for those who prefer the new integrated development environment Android Studio. Apart from that, you can choose any of these two JDKs as you benefit from standard Java libraries while developing Android applications.

While OpenJDK is easy to install with the package manager on most Linux distributions, it takes a few extra steps to install the JDK offered by Oracle. Licensing states somewhat affect the way it is deployed. You can install whatever you want by following the steps below.

OpenJDK installation
Although your package manager will vary depending on the Linux distribution you are using, the package you need to install is usually called openjdk-11-jdk. You can install this package via Terminal in Ubuntu Linux in this order:

First, update your package list by typing the command:

 

sudo apt-get update

Then install openjdk-7-jdk and openjdk-7-jre with the following command:

 

sudo apt-get install openjdk-11-jdk openjdk-11-jre

OpenJDK will be installed on your system after you give your approval with the "E" key to install the dependencies. to console

 

java -version

You can see that you are using the latest version of OpenJDK when you issue the command.

Oracle JDK installation
Oracle JDK is not included in the official Ubuntu repositories for some licensing reasons. However, it is still possible to install it with the package manager. For this, we will make use of the repository created by the volunteers and a package there. The WebUpd8 team, which is followed by a large Ubuntu user base around the world, has created a repository for us.

First we will add this package to our repository. Open Terminal and issue the command:

 

sudo add-apt-repository ppa:webupd8team/java

Then update your package list with this command so that the packages from this new repository are also available:

 

sudo apt-get update

Now, install the package that will download and prepare the Oracle JDK for us with the command:

sudo apt-get install oracle-java11-set-default oracle-java11-installer oracle-jdk11-installer

After this command, the JDK package suitable for your system will be downloaded and installed from Oracle's servers. The duration of this may vary depending on your connection speed.

After installing the JDK, back to the console:

 

java -version

You can see which version of Java you are using by giving the command.