Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Google Cloud

How to Install Java on Ubuntu 20.04

by Cloudbooklet
3 years ago
in Google Cloud
How To Install Java On Ubuntu 20.04
ShareTweetSendShare
Readers like you help support Cloudbooklet. When you make a purchase using links on our site, we may earn an affiliate commission.

How to Install Java on Ubuntu 20.04. Java is one of the most popular programming languages which is widely used to built applications. It runs on all major operating systems and devices. In this guide you are going to learn how to install Java Runtime Environment (JRE), Java Development Kit (JDK) and Open JDK. Available […]

ADVERTISEMENT

How to Install Java on Ubuntu 20.04. Java is one of the most popular programming languages which is widely used to built applications. It runs on all major operating systems and devices.

In this guide you are going to learn how to install Java Runtime Environment (JRE), Java Development Kit (JDK) and Open JDK.

Available Java versions in Ubuntu 20.04

By default Ubuntu 20.04 repositories include two OpenJDK packages, Java Runtime Environment (JRE) and Java Development Kit (JDK).

ADVERTISEMENT

If you are not sure what to install you can choose the default OpenJDK (JDK 11) version.

You might also like

How To Setup Ssh Keys On Ubuntu

How to Setup SSH Keys on Ubuntu 20.04

4 months ago
Draggan Ai Editing Tool Install And Use Draggan Photo Editor

DragGAN AI Editing Tool Install and Use DragGAN Photo Editor

4 months ago

Start by updating the packages and install Java OpenJDK 11.

sudo apt update
sudo apt upgrade

Install Java OpenJDK 11

At the time of writing Java 11 is the latest long term supported version available. This is the default version on Ubuntu 20.04.

ADVERTISEMENT

Install Java 11 using the following commands.

 sudo apt install openjdk-11-jdk 

Once the installation is completed you can verify the Java version using the following command.

ADVERTISEMENT
 java -version 

You will receive an output similar to the one below.

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing) 

Now you have installed Java 11 on your Ubuntu 20.04.

ADVERTISEMENT

Install Java OpenJDK 8

If your application is built using Java 8, you can install it using the following commands.

 sudo apt install openjdk-8-jdk 

Once the installation is completed you can verify the Java version using the following command.

ADVERTISEMENT
 java -version 

You will receive an output similar to the one below.

openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

Now you have installed Java 8 on your Ubuntu 20.04.

Switch between Java Versions

If you have multiple Java versions installed, you can change the version easily using the following command.

 sudo update-alternatives --config java 

This command prompts you to choose Java version.

There are 2 choices for the alternative java (providing /usr/bin/java).
 Selection    Path                                            Priority   Status
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
Press  to keep the current choice[*], or type selection number: 

Choose the number and press Enter.

Configure JAVA_HOME Environment Variable

To setup path you need to find the installation path using the update-alternatives command.

 sudo update-alternatives --config java 

Here you will see the path of Java.

  • OpenJDK 11 is located at /usr/lib/jvm/java-11-openjdk-amd64/bin/java
  • OpenJDK 8 is located at /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

Now you can add this to the environment file.

 sudo nano /etc/environment

Now add the path as shown below, here shown the method to add Java 11 to the path.

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

For the changes to be applied either logout and login or execute the following command for the current session.

source /etc/environment 

To verify the environment variable of Java

echo $JAVA_HOME

You will get the installation path you just set.

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

That’s all.

Conclusion

Now you have learned how to install Java and configure JAVA_HOME on Ubuntu 20.04.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Tags: Ubuntu 20.04
ShareTweetSendShare
Cloudbooklet

Cloudbooklet

Leave a Reply Cancel reply

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

Related Posts

Set Up Deep Learning With Nvidia, Cuda, Cudnn On Ubuntu

How to Set Up Deep Learning with Nvidia, CUDA, cuDNN on Ubuntu 22.04

7 months ago
How To Install Or Upgrade Php 8.2 On Ubuntu 22.04

How to Install or Upgrade PHP 8.2 on Ubuntu 22.04

9 months ago
How To Change Timezone On Ubuntu 22.04

How to Change Timezone on Ubuntu 22.04

1 year ago
How To Install Ansible On Ubuntu 22.04

How to Install Ansible on Ubuntu 22.04

1 year ago

Follow Us

Trending Articles

Wix Ai

Create a Professional Website with Wix AI Website Builder

September 19, 2023

AI Powered 3D Models to Create 3D Designs in Breeze

How to Use ChatGPT to Translate Your Website or Blog

Wondershare Virbo AI Video Creation with New Features

Microsoft Unveils New Disc-Less Xbox Series X with Lift-to-Wake Controller

10 Best AI Song Generator in 2023 (Free and Paid)

Popular Articles

Ai Comic Generator

Best 10 AI Comic Generator: Create Comic book in Seconds

September 18, 2023

How to Upscale Image with Stable Diffusion Models

10 Best Minecraft Server Hosting Providers in 2023

Bigjpg AI: Best AI Image Upscaler for Super Resolution

How to Stabilize Videos for Free with Online Video Stabilizer

Top 10 AI Presentation Maker: Easy Way to Create Stunning Presentations

Subscribe Now

loader

Subscribe to our mailing list to receives daily updates!

Email Address*

Name

Cloudbooklet Logo

Welcome to our technology blog, where we explore the latest advancements in the field of artificial intelligence (AI) and how they are revolutionizing cloud computing. In this blog, we dive into the powerful capabilities of cloud platforms like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure, and how they are accelerating the adoption and deployment of AI solutions across various industries. Join us on this exciting journey as we explore the endless possibilities of AI and cloud computing.

  • About
  • Contact
  • Disclaimer
  • Privacy Policy

Cloudbooklet © 2023 All rights reserved.

No Result
View All Result
  • News
  • Artificial Intelligence
  • Applications
  • Linux

Cloudbooklet © 2023 All rights reserved.