How To Install Java On Ubuntu 22.04

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

How to Install Java on Ubuntu 22.04 https://linuxhint.

com/install-java-ubuntu-22-04/

HOME LEARNING VIDEOS SUBSCRIBE 

Ubuntu

How to Install Java on Ubuntu 22.04


12 months ago • by Sharqa Hameed

Java is a general-purpose and free-to-use programming language utilized for


creating distributed and localized applications. This programming language is also
used to develop computer, video, and mobile games. It assists in creating modern
games that incorporate complex technology such as virtual reality and machine
learning.

Components of Java
The Java programming language is based on these three primary components:

–JVM: JVM or “Java Virtual Machine” is an engine that converts the Java byte
code into machine language.

MY LATEST VIDEOS

1 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

–JRE: JRE or “Java Runtime Environment” creates an environment where Java-


related files are executed.00:23
It is/ 01:00
a software bundle that comprises JVM, Java
Classloader, and libraries.

–JDK: JDK is an acronym for “Java Development Kit“, and it offers a software
development environment for building Java applications.

This write-up will discuss the procedure to install the latest Java version on
Ubuntu 22.04 using two different methods. So, let’s start!

66 28 16 25

How To Install Zlib How to Install How to Install How to install and How to install and
on Ubuntu 22.04 Bitcoin Core in… Metasploit… use gThumb on… use xpad on

How to install OpenJDK 18 on Ubuntu 22.04


OpenJDK comprises separate packages for JDK and JRE for developing and
running Java-based applications.

2 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

Want to install OpenJDK on Ubuntu 22.04? If yes, then follow the below-given
procedure.

Step 1: Update system repositories


Press “CTRL+ALT+T” to open the terminal of Ubuntu 22.04 and run the below-
given commands to update system repositories:

$ sudo apt update

Step 2: Install OpenJDK 18 on Ubuntu 22.04


Based on your preferences, install OpenJDK or JRE on your system. Here is the
command that assists in installing OpenJDK18 on Ubuntu 22.04:

3 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

$ sudo apt install -y openjdk-18-jdk

4 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

Step 3: Install OpenJDK18 JRE on Ubuntu 22.04


In the other case, install OpenJDK 18 JRE by utilizing the following command:

$ sudo apt install -y openjdk-18-jre

5 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

Promo Service Astra Daihatsu


Diskon 20% dengan Minimal Transaksi
Rp300.000, Service Kendaraanmu Sekarang!

That’s it! OpenJDK 18 JRE on your Ubuntu 22.04 system.

How to install Java SE Development Kit 18 on Ubuntu 22.04


You can also utilize the Java SE Development Kit for the development as it
offers several tools for writing, compiling, debugging, and executing Java
applications.

6 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

For the installation of Java SE Development Kit 18 on your Ubuntu 22.04 system,
check out the below-given procedure.

Step 1: Update system repositories


Press “CTRL+ALT+T” to open the terminal of Ubuntu 22.04 and run the below-
given commands to update system repositories:

$ sudo apt update

Step 2: Install required dependencies


In the next step, we will install the required dependencies for the Java SE
Development Kit 18:

$ sudo apt install -y libc6-x32 libc6-i386

7 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

8 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

Step 3: Download Java SE Development Kit 18


Then, download the Java SE Development Kit 18 package from the official
page with the help of the following “wget” command:

$ wget https://download.oracle.com/java/18/latest/jdk-18_linux-x64_bin.deb

9 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

Step 4: Install Java SE Development Kit 18 on Ubuntu


Next, utilize the below-given command for the installation of Java SE
Development Kit 18 on Ubuntu 22.04:

$ sudo apt install ./jdk-18_linux-x64_bin.deb

10 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

Step 5: Configure Java Environment


After installing the mentioned Java Kit package, you have to configure the Java
environment. To do so, one by one execute the given command in Ubuntu 22.04
terminal:

$ cat <<EOF | sudo tee /etc/profile.d/jdk18.sh


> export JAVA_HOME=/usr/lib/jvm/jdk-18
> export PATH=\$PATH:\$JAVA_HOME/bin
> EOF

11 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

Now, write out the “source” command to execute the profile file “jdk18.sh”:

$ source /etc/profile.d/jdk18.sh

Step 6: Verify Java version


Lastly, validate the version of the installed Java on Ubuntu 22.04:

$ java -version

12 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

We have compiled two different methods for the installation of Java on Ubuntu
22.04. Select any of them according to your requirements.

Conclusion
To install the latest Java version on Ubuntu 22.04, either execute “$ sudo
apt install -y openjdk-18-jdk” or the “$ sudo apt install -y openjdk-18-jre”
command. You can also download the Java SE Development Kit from the
official page and install it with the help of the “$ sudo apt install ./jdk-
18_linux-x64_bin.deb” command. This write-up discussed two different methods
to install Java on Ubuntu 22.04.

13 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

Explore More
search text

ABOUT THE AUTHOR

Sharqa Hameed
I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold
masters degree in computer science and am passionate about learning and
teaching.

View all posts

14 of 15 6/9/23, 13:50
How to Install Java on Ubuntu 22.04 https://linuxhint.com/install-java-ubuntu-22-04/

RELATED LINUX HINT POSTS

How to Install CUDA on Ubuntu


22.04 LTS

How to Take Screenshots from the


Login Shell (CLI) of
Ubuntu/Debian Server

Troubleshooting “E: Unable to


locate package” Error on Ubuntu

How to Install and Use the


Handbrake on Ubuntu 22.04

How to Install and Use AIDE on


Ubuntu 22.04

How to Install and Use Monit on


Ubuntu 22.04

How to Install and Use Rkhunter


for Security on Ubuntu 22.04

Linux Hint LLC, editor@linuxhint.com


1309 S Mary Ave Suite 210, Sunnyvale, CA
94087
Privacy Policy and Terms of Use

A RAPTIVE PARTNER SITE

15 of 15 6/9/23, 13:50

You might also like