Java and the JVM (Java’s virtual machine) are required for many kinds of software, including Tomcat, Jetty, Glassfish, Cassandra, and Jenkins.

OpenJDK (Open Java Development Kit) is a free and open-source implementation of the Java Platform Standard Edition. It includes both the Java Runtime Environment (JRE) and the Java Development Kit (JDK), required to run and develop Java applications. 

This article explains how to install OpenJDK Java 11 or 8 on an Ubuntu-based system.

You can follow the steps in this article to install JAVA OpenJDK in all Ubuntu versions. 

Step 1: OpenJDK packages are available under the native apt repository.

Run the following command to list all available OpenJDK packages for Ubuntu OS:

# apt-cache search openjdk

You should see options like openjdk-11-jre and openjdk-11-jdk in the list.

Step 2: Execute the command given below:
# sudo apt-get install openjdk-11-jre openjdk-11-jdk

This will install the Java Development Kit (JDK) and Java Runtime Environment (JRE). It will show that after running this command, 553 MB of additional disk space will be used. Type Y.

Step 3: Verify the Java version using the below-mentioned command:
# java -version

Output:

openjdk version "11.0.6" 2020-01-14

OpenJDK Runtime Environment (build 11.0.27+6-post-Ubuntu-0ubuntu124.04)

Step 4: Now, set the Java environment variable by adding the JAVA_HOME path to the system environment file /etc/environment:
 echo "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/" >> /etc/environment
# source /etc/environment
Step 5: Finally, verify the environment value.
# echo $JAVA_HOME

This is all you have to do to install the OpenJDK Java 11 on Ubuntu.

Conclusion:

You have now successfully installed OpenJDK Java 11 on your Ubuntu system. This setup includes the JRE and JDK, enabling you to run and develop Java applications. Don’t forget to configure the JAVA_HOME variable for consistent environment use across applications. You can follow similar steps to install OpenJDK 8 by replacing the package names accordingly.

Was this answer helpful? 0 Users Found This Useful (2 Votes)