In this article we will cover “Java 18 Installation on Ubuntu 20.04 LTS using curl [5 Steps] “.-

Introduction:

Java 18 is the latest version of the popular programming language and runtime environment. In this tutorial, we’ll walk you through the steps to install Java 18 on Ubuntu 20.04 LTS and set up the necessary environmental variables for your development environment.

Prerequisites:

Before we begin, make sure you have the following prerequisites:

  1. A user account with sudo privileges.
  2. An updated Ubuntu 20.04 LTS system.
  3. curl or wget downloader
ubuntu@Rushi-InfoTech:~$ sudo apt install -y curl wget

Let’s start “Java 18 Installation on Ubuntu 20.04 LTS using curl [5 Steps]”.

Steps of “Java 18 Installation on Ubuntu 20.04 LTS using curl [5 Steps]”

Step #1:Update Your Ubuntu 20.04 LTS

To begin, open a terminal and update your system to ensure you have the latest package information:

ubuntu@Rushi-InfoTech:~$ sudo apt-get update

Step #2:Download Java 18 file using curl

Visit JDK 18 releases page to download the latest archive.:

ubuntu@Rushi-InfoTech:~$ curl -O https://download.java.net/java/GA/jdk18/43f95e8614114aeaa8e8a5fcf20a682d/36/GPL/openjdk-18_linux-x64_bin.tar.gz

Step #3:Extract Downloaded file

Extract downloaded file using tar command.:

ubuntu@Rushi-InfoTech:~$ tar xvf openjdk-18_linux-x64_bin.tar.gz
  • Move the resulting folder to /opt directory.
ubuntu@Rushi-InfoTech:~$ sudo mv jdk-18 /opt/

Step #4:Configure Java environment

Configuring java environmental variables can be useful for managing Java versions and ensuring that Java-based applications run smoothly.

ubuntu@Rushi-InfoTech:~$ sudo tee /etc/profile.d/jdk18.sh <<EOF
export JAVA_HOME=/opt/jdk-18
export PATH=\$PATH:\$JAVA_HOME/bin
EOF
  • Source your profile file and check Java command
ubuntu@Rushi-InfoTech:~$ source /etc/profile.d/jdk18.sh
  • Verify the java version by the below command.
ubuntu@Rushi-InfoTech:~$ java -version

Step #5:Verify Environmental Variables

Confirm that the environmental variables are set correctly by running these commands:

ubuntu@Rushi-InfoTech:~$ echo $JAVA_HOME
ubuntu@Rushi-InfoTech:~$ echo $PATH

These commands should display the Java installation directory and include it in the PATH.

Conclusion:

Congratulations! You have successfully installed Java 18 on your Ubuntu 20.04 LTS system and configured the essential environmental variables. You are now equipped to develop and run Java applications with the latest Java 18 version. Happy coding!

From this article we have learnt “Java 18 Installation on Ubuntu 20.04 LTS using curl [5 Steps]”

Any queries pls contact us
https://rushiinfotech.in/contact/

Similar Posts

Leave a Reply

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