Skip to content

How to Install OpenJDK JAVA 11/8 in Ubuntu and Debian

Install JAVA (OpenJDK) on Ubuntu Systems. This Article will help you to Install JAVA on Ubuntu System in easy steps. Installing OpenJDK on Ubuntu.

Steps
4
Category
Linux
Covers
Debian, Java, Ubuntu
Versions & support
About Java →, About Debian →
On this page 4 steps

This tutorial will help to install JAVA (OpenJDK) on all versions of Ubuntu, Debian, and LinuxMint systems. You can also use this tutorial to install Java on any Debian based systems. Let’s follow the below simple steps for the installation.

Step 1 of 4Search OpenJDK Packages

OpenJDK packages are available under native apt repositories. You can simply use apt-cache search command to search the available java version for your Ubuntu system.

apt-cache search openjdk

As per above output, you can see openjdk-11-* and openjdk-8-* is available in the package manager.

Step 2 of 4Install JAVA (OpenJDK)

Use the below command to install OpenJDK on your Debian based systems using the package manager from the default repository. The below commands will install Java Development Kit (JDK) and Java Runtime Environment (JRE) both on your system. You can install JRE package only to setup Runtime Environment only.

OpenJDK 11

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

OpenJDK 8

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

Step 3 of 4Configure Default Java Version

After installation of Java uses below command to verify the installed version of Java on your system.

java -version

openjdk version "11.0.4" 2019-07-16 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.4+11-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.4+11-LTS, mixed mode, sharing)

Step 4 of 4Set JAVA_HOME

Its the best practice to set Java environment variable after installing java. To setup JAVA_HOME add following line to /etc/environment file, Path may be differ with your system architecture.

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

Use the following command to check the environment value

echo $JAVA_HOME

/usr/lib/jvm/java-11-openjdk-amd64/

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

7 Comments

  1. Thank you for the information.

    I’m a Debian user, and this command “update-alternatives –config java” instead “Step 4” work fine for me, always as root user.

    I hope my comment can help some one.

    Sorry my english, I’m novice.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top