You have multiple options to develop a Java application on Linux (Ubuntu or Debian).
Use OpenJDK (Open Java Development Kit), an open and free implementation of the standard Java platform, or use Oracle Java SE JDK from Oracle. Oracle JDK is recommended by the IDE developer (Google), especially for those who prefer the new integrated development environment Android Studio. Other than that, you can choose between these two JDKs as you use standard Java libraries while developing an Android app.
While it is easy to install OpenJDK in most Linux distributions with the package manager, it is necessary to take a few additional steps to install the JDK that Oracle offers. License status affects the way of distribution slightly. You can follow the steps you want to install.
Although your package manager may vary depending on the Linux distribution you use, the package you need to install is usually called
OpenJDK-11-JDK. You can install this package on Ubuntu Linux through Terminal in the following order:
First, update your package list by typing the following command:
sudo apt-get update
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” button to install dependencies. Console
You can see that you are using the latest version of OpenJDK.
Oracle JDK installation
Oracle JDK is not included in official Ubuntu repositories for some license reasons. However, it is still possible to install it with the package manager. For this, we will benefit from the warehouse where volunteers create and a package there. The WebUpd8 team, which is followed by the world’s largest Ubuntu users, has created a repository for us.
First of all, we will add this package to our warehouse. Open the terminal and give the following command:
sudo add-apt-repository ppa:webupd8team/java
Then update your package list with the following command so that the packages in this new repository are also accessible:
sudo apt-get update
Now install and install the Oracle JDK package with the following command:
sudo apt-get install oracle-java11-set-default oracle-java11-installer oracle-jdk11-installer
After this command, the appropriate JDK package from your Oracle servers will be downloaded and installed. This may vary depending on your connection speed.
After reinstalling the JDK, rebuild the console:
You can see which Java version you are using.