1. Introduction
Java is one of the most popular object-oriented programming languages used worldwide by developers on many platforms. With Java, we can create cross-platform modern applications for multiple purposes.
JDK (Java Development Kit) contains a complete set of Java tools required for development:
- the Java Runtime Environment (JRE),
- an interpreter/loader (java),
- a compiler (javac), an archiver (jar),
- a documentation generator (javadoc)
- and other tools needed in development.
In this article, we will focus on OpenJDK which is an open-source implementation of Oracle JDK. It was released in 2007 by Sun Microsystems that started working on this language in 2006.
2. Prerequisites
You must be logged in as a user with sudo privileges.
3. Installing default OpenJDK (the latest version)
To install OpenJDK in the latest available version please follow the below steps. At the time this article was writing the latest LTS version of Java was version 11.
1. On the first step we should update apt
package index using the following command:
2. When the package index is updated install the default Java OpenJDK package with:
3. To verify the installation, enter below command that will print the Java version:
The output of this command should look, more or less like:
4. Installing OpenJDK 8
Java 8 is still very popular because it brings a lot of new and interesting features to the programming world. Follow these steps if you need to install OpenJDK 8:
1. First, update the APT package repository with the following command:
2. To install Java OpenJDK in version 8 use the following command:
5. Installing OpenJDK 12
OpenJDK 12 has two versions: full and headless. If you don't need to run the Java application that required standalone GUI uses a headless version.
1. First, update the APT package repository:
2.1. Install Java OpenJDK 12 full version with the following command:
2.2. Install Java OpenJDK 12 headless version with the following command:
6. Conclusion
In this article, we described how to install various versions of OpenJDK on Ubuntu. The process of installation is easy - mostly required only three commands entered on the console. Oracle JDK from version 11 will require a commercial license, so OpenJDK is a great alternative for those who don't want to pay.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}