How to Install OpenJDK JAVA 11/8 on Ubuntu? Print

  • 0

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

1. OpenJDK Packages is available under the native apt repository.
The command given below will find the available java version for Ubuntu OS – 

# apt-cache search openjdk

      Here, OpenJDK JAVA 11 should be present within the list.

2. Execute the command given below –  

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

This will install Java Development Kit (JDK) and Java Runtime Environment (JRE).

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.6+10-post-ubuntu-1ubuntu118.04.1)

OpenJDK 64-Bit Server(build 11.0.6+10-post-ubuntu-1ubuntu118.04.1, mixed mode, sharing)

4. Now, set the Java environment variable by adding the command given below to /etc/environment –

# echo "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/" >> /etc/environment
# source /etc/environment

5. Finally, verify the environment value.

# echo $JAVA_HOME
Output :

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


Was this answer helpful?

« Back