How to Install Openjdk-11 in Ubuntu

This tutorial will help you install OpenJDK 11 on your Ubuntu machine.

For Windows, you can simply download the zip distributable provided by RedHat at https://developers.redhat.com/products/openjdk/download.

Before you begin, change your user to root first.
sudo su -
Otherwise, append sudo on all the commands.

1. Update Ubuntu packages.

apt-get update

2. Make sure that you have OpenJDK packages.

This should always work on new Ubuntu installation (v20.x)

apt-cache search openjdk-11

3. Install Open JDK and JRE.

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

4. Check the installed version.

java -version

5. Configure the default version (if you have more than 1 version).

update-alternatives --config java
If you only have 1 version, it will display a message "Nothing to configure", otherwise select the version that you want to use.

6. Set the JAVA_HOME environment.

Open the file ~/.profile
vi ~/.profile -- create the file if it doesn't exists
// append the following lines at the end of the file
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
// add Java bin folder to Ubuntu's path
PATH=$JAVA_HOME\bin:$PATH

7. Check JAVA_HOME environment.

echo $JAVA_HOME

8. Restart Ubuntu.

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post
NERV Open Source
Building production Spring Boot systems?

Explore NERV — open-source Java libraries for audit trails, persistence, exception handling, and reliable event-driven architecture.