Adobe Introduces Powerful Generative AI Tools in Photoshop
Artificial Intelligence

Adobe Introduces Powerful Generative AI Tools in Photoshop Beta

by Veronica
June 1, 2023
2

Adobe Photoshop beta AI will take your creativity to the...

Read more
Adobe Photoshop's Generative Fill Feature

Exploring the Power of Adobe Photoshop’s Generative Fill Feature

June 1, 2023
ChatGPT app

The Easiest Way to Download ChatGPT App Free

June 1, 2023
Nvidia Unveils Futuristic Gaming Experience at Computex 2023

Nvidia Unveils Futuristic Gaming Experience at Computex 2023, Blending Gaming and AI

May 29, 2023
NVIDIA and Microsoft Partner to Accelerate AI

NVIDIA and Microsoft Partner to Accelerate AI

May 25, 2023
How to use Auto GPT and Agent GPT

How to Use Auto GPT and Agent GPT

May 4, 2023
Prompt Engineering

Prompt Engineering: Key Concepts & Use Cases

May 8, 2023
Google help me write

Google’s New “Help Me Write” Feature Makes Emailing Faster and Easier

May 16, 2023
AI Ethics: How to Ensure Responsible Development and Use of Artificial Intelligence

AI Ethics: How to Ensure Responsible Development and Use of Artificial Intelligence

April 12, 2023
e2b: The Open-Source Platform for Building AI-Powered Virtual Software Developers

e2b: The Open-Source Platform for Building AI-Powered Virtual Software Developers

May 17, 2023
How to access ChatGPT 4 for free

How to Access ChatGPT 4 for Free

April 26, 2023
Cloudbooklet
  • News
  • Artificial Intelligence
  • Linux
  • Google Cloud
  • AWS
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Linux
  • Google Cloud
  • AWS
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Linux

How to Install Java on Ubuntu 22.04

by Cloudbooklet
May 19, 2023
in Linux
Reading Time: 7 mins read
How to Install Java on Ubuntu 22.04
Share on FacebookShare on TwitterShare on WhatsAppShare on Telegram

How to Install Java on Ubuntu 22.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 multiple versions of Java (11, 17, 18) Runtime Environment (JRE), Java Development Kit (JDK) and Open JDK.

You might also like

Best PHP-FPM Configuration - Easy and Simple Calculation

Best PHP-FPM Configuration – Easy and Simple Calculation

June 1, 2023
How to Use ChatGPT in Linux Terminal

How to Use ChatGPT in Linux Terminal

May 19, 2023

You will also learn how to switch between Java versions and also the Java Development kit versions.

Available Java versions in Ubuntu 22.04

Start by updating the packages to the latest version available.

sudo apt update
sudo apt upgrade

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

To check the available packages you can use the following command.

sudo java -version
Output
Command 'java' not found, but can be installed with:
apt install openjdk-11-jre-headless  # version 11.0.15+10-0ubuntu0.22.04.1, or
apt install default-jre              # version 2:1.11-72build2
apt install openjdk-17-jre-headless  # version 17.0.3+7-0ubuntu0.22.04.1
apt install openjdk-18-jre-headless  # version 18~36ea-1
apt install openjdk-8-jre-headless   # version 8u312-b07-0ubuntu1
Ask your administrator to install one of them.

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

Install Java Runtime 11

Execute the following command to install the default Java Runtime Environment (JRE), which will install the JRE from OpenJDK 11

 sudo apt install default-jre

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

 java -version 

You will receive an output similar to the one below.

openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1, mixed mode, sharing)

Now you have installed Java 11 Runtime on your Ubuntu 22.04.

Install Java Development Kit

If need Java Development Kit to compile Java programs, you can also install Open JDK

 sudo apt install default-jdk

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

 java -version 

You will receive an output similar to the one below.

javac 11.0.15

Now you have installed Java Development Kit on your Ubuntu 22.04.

Install Java JDK 17

Execute the following command to install the default Java JDK, which will also install the JRE from OpenJDK 17.

 sudo apt install openjdk-17-jdk

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

 java -version 

You will receive an output similar to the one below.

openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+7-Ubuntu-0ubuntu0.22.04.1)
OpenJDK 64-Bit Server VM (build 17.0.3+7-Ubuntu-0ubuntu0.22.04.1, mixed mode, sharing)

Now you have installed Java 17 Runtime on your Ubuntu 22.04.

Install Java JDK 18

Execute the following command to install the default Java JDK, which will also install the JRE from OpenJDK 18.

 sudo apt install openjdk-18-jdk

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

 java -version 

You will receive an output similar to the one below.

openjdk version "18-ea" 2022-03-22
OpenJDK Runtime Environment (build 18-ea+36-Ubuntu-1)
OpenJDK 64-Bit Server VM (build 18-ea+36-Ubuntu-1, mixed mode, sharing)

Now you have installed Java 18 Runtime on your Ubuntu 22.04.

Switch between Java (JRE) 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 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-18-openjdk-amd64/bin/java   1811      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      manual mode
  2            /usr/lib/jvm/java-17-openjdk-amd64/bin/java   1711      manual mode
  3            /usr/lib/jvm/java-18-openjdk-amd64/bin/java   1811      manual mode

Press <enter> to keep the current choice[*], or type selection number:

Choose the number and press Enter.

Switch between Java (JDK) Versions

You must also change the Java development kit version, otherwise you might get into compatibility issues.

To change the javac version you can use the below command.

sudo update-alternatives --config javac

This command prompts you to choose Java Development version.

There are 3 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                          Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-18-openjdk-amd64/bin/javac   1811      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/javac   1111      manual mode
  2            /usr/lib/jvm/java-17-openjdk-amd64/bin/javac   1711      manual mode
  3            /usr/lib/jvm/java-18-openjdk-amd64/bin/javac   1811      manual mode

Press <enter> to keep the current choice[*], or type selection number:

Choose the number and press Enter.

Now you have configured the Java Development Kit version also.

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 17 is located at /usr/lib/jvm/java-17-openjdk-amd64/bin/java
  • OpenJDK 18 is located at /usr/lib/jvm/java-18-openjdk-amd64/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.

Take your first step towards a career in Java software development with this introduction course

Conclusion

Now you have learned how to install multiple versions of Java 11, 17 or 18 and configure JAVA_HOME on Ubuntu 22.04.

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

Tags: JavaUbuntu 22.04
ShareTweetSendShare
Cloudbooklet

Cloudbooklet

Help us grow and support our blog! Your contribution can make a real difference in providing valuable content to our readers. Join us in our journey by supporting our blog today!
Buy me a Coffee

Related Posts

Install WordPress with Docker Compose, Nginx, Apache with SSL

WordPress Deployment Made Easy: Docker Compose, Nginx, Apache, SSL Setup Guide

May 20, 2023
How to Install WordPress on Docker

How to Install WordPress on Docker for Windows, macOS, and Linux

May 20, 2023
How to install python on Ubuntu

How to Install Python on Ubuntu 22.04?

May 31, 2023
what's new in node.js 20

What’s new in Node.js 20?

April 23, 2023

Leave a Reply Cancel reply

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

I agree to the Terms & Conditions and Privacy Policy.

  • Trending
  • Comments
  • Latest
DragGAN The AI-Powered Image Editing Tool

DragGAN: The AI-Powered Image Editing Tool That Makes Editing Images Easy

May 30, 2023
DragGAN AI editing Tool Install and Use DragGAN Photo Editor

DragGAN AI editing Tool Install and Use DragGAN Photo Editor

May 27, 2023
Bard API key

Everything You Need to Know About Google’s Bard API Key

May 20, 2023
Install PHP 8.1 on Ubuntu

How to Install or Upgrade PHP 8.1 on Ubuntu 20.04

May 17, 2023
DragGAN The AI-Powered Image Editing Tool

DragGAN: The AI-Powered Image Editing Tool That Makes Editing Images Easy

79
Upgrade PHP version to PHP 7.4 on Ubuntu

Upgrade PHP version to PHP 7.4 on Ubuntu

28
Install Odoo 13 on Ubuntu 18.04 with Nginx - Google Cloud

Install Odoo 13 on Ubuntu 18.04 with Nginx – Google Cloud

25
Best Performance WordPress with Google Cloud CDN and Load Balancing

Best Performance WordPress with Google Cloud CDN and Load Balancing

23
Best PHP-FPM Configuration - Easy and Simple Calculation

Best PHP-FPM Configuration – Easy and Simple Calculation

June 1, 2023
ChatGPT Shared Links

ChatGPT Shared Links: A New Way to Share Your Conversations

June 1, 2023
Deepfake

Deepfake: The Rise of Synthetic Media

June 1, 2023
How to Setup SSH Keys on Ubuntu

How to Setup SSH Keys on Ubuntu 20.04

May 31, 2023

Popular Articles

  • DragGAN The AI-Powered Image Editing Tool

    DragGAN: The AI-Powered Image Editing Tool That Makes Editing Images Easy

    1517 shares
    Share 607 Tweet 379
  • DragGAN AI editing Tool Install and Use DragGAN Photo Editor

    399 shares
    Share 160 Tweet 100
  • Auto-Photoshop-Stable Diffusion-Plugin: A New Way to Create AI-Generated Images in Photoshop

    71 shares
    Share 28 Tweet 18
  • InternGPT: A New Way to Interact with ChatGPT

    56 shares
    Share 22 Tweet 14
  • Microsoft research Reveals GPT-4 AI Shows Promising Signs of Common Sense and Human-Like Reasoning

    99 shares
    Share 40 Tweet 25
Latest Technology Trends in Artificial Intelligence and Machine Learning with Cloudbooklet

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
  • Linux
  • Google Cloud
  • AWS

Cloudbooklet © 2023 All rights reserved.

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.