How to install Java on Linux?

This article describes the process of installing Java on your Linux PC. You will need java on your PC if you want to run some Java based software on your PC or if you want to develop Java based software. For running a Java software you will need to install only Java Runtime Environment i.e. JRE. Whereas, if you want to develop a Java based software you will need to install Java Development Kit i.e. JDK. You may note here that if you install JDK there will be no need to install JRE as JDK package includes JRE by default. Let us see the process to install open source java also referred as open JDK or open JRE on Linux computers.

Let us first see how to check and install JRE on a Linux PC then we will see the process to check and install JDK on Linux PC. For both, open terminal on Linux PC:

Then use the commands mentioned below:

A. How to install JRE on Linux?

Execute the following command on Linux terminal to install open JRE:

sudo apt install default-jre

Type in the admin user’s password and press Enter to start JRE installation. Press ‘y’ when asked to download and install to continue download of open JRE package and finish installation. Once, the download is complete, you can use the following command to check whether java is installed on your Linux PC:

java -version

If the above command, displays the version of Java it means that Java Runtime Environment is successfully installed on your PC.

B. How to install JDK on Linux?

Execute the following command on Linux terminal to install open JDK:

sudo apt install default-jdk

Type in the admin user’s password and press Enter to start JDK installation. Press ‘y’ when asked to download and install to continue download of open JDK package and finish installation. Once, the download is complete, you can use the following command to check whether Java Development Kit is installed on your Linux PC:

javac -version

If the above command, displays the version of Java it means that Java Runtime Environment is successfully installed on your PC.

Note: pay attention that java -version command is used for checking JRE version, whereas, javac -version command is used for checking JDK version respectively.

You can watch the practical demonstration of above process in following video:

For more information you can visit official website of open source Java platform.


We hope the above information was useful for you. Alas! Information keeps on updating. Follow us on social media, subscribe to our blog or subscribe our YouTube Channel to receive latest updates.


Share

This website uses cookies.

Privacy Policy