Friday, October 30, 2020

Install Java on CentOS 7 Operating System

Must read

How to Setup a Firewall with UFW on Ubuntu 20.04

Nowadays, a Firewall is an essential utility and property of any system for security; by default Ubuntu Operating system having a firewall...

How to Install Ruby on Ubuntu 20.04 Linux

Nowadays, Ruby is the most popular language, especially for SaaS application development. It has a perfect and elegant syntax structure, and it...

How to Install Eclipse IDE on Ubuntu 20.04 Linux

Eclipse is the most famous and widely used Java integrated development environment (IDE). It supports many plugins to enhance the capabilities to...

The 30 most useful Linux commands

This article will introduce some practical and common Linux or Unix command , which is the Linux system administrators normally use the command . This article is not a...
SATISH KUMAR
I am Satish Kumar, Founder of LinuxConcept. Linux and F.O.S.S enthusiast, love to work on open source platform and technologies.
- Advertisement -

Java is the most popular programming language, use to build various type of applications like a desktop application, web application, mobile application, etc.

The Java comes in two different packages, one is Java Runtime Environment (JRE), and another one is Java Development Kit (JDK).

- Advertisement -

When we need to run a Java-based application or java program, we need only Java Runtime Environment, but if you want to develop Java application, you need to Java Development Kit (JDK)JDK includes both JRE and debugging tools and development libraries.

Java also has two different flavors, one is Open JDK, and another one is Oracle Java, both have the same functionalities and capabilities, the only difference is Oracle Java has some more commercial features. The default Java flavor of Linux Operating System is OpenJDK.

If you are a little bit confuse to choose between OpenJDK and Oracle Java, you can stick with default OpenJDK available on CentOS 7.

In this tutorial article, we will walk through the process to install Java on CentOS 7 machine.

Prerequisites

Before continuing this tutorial, make sure you have CentOS 7 installed machine and a user to login into the system with sudo privileges.

OpenJDK Installation

- Advertisement -

Install OpenJDK 8 JDK

OpenJDK 8 is the most widely-used version of Java. If your application required old version 8 of Java, you could install it by using below command.

$ sudo yum install java-1.8.0-openjdk-devel

Install OpenJDK 8 JRE

If you only want to run a java application, you can install OpenJDK 8 JRE (Java Runtime Environment) by using the following command:

- Advertisement -
$ sudo yum install java-1.8.0-openjdk

You can verify java installation by checking the version of installed Java, as shown below:

$ java –version

If OpenJDK installed you will get the output like below image:

Now OpenJDK 8 is installed successfully into your CentOS 7 machine.

Install OpenJDK 11 JDK

OpenJDK 11 is the latest version of Java; you can install it in your CentOS 7 machine by using the following command:

$ sudo yum install java-11-openjdk-devel

You can verify OpenJDK 11 installation by checking the version of installed java, as shown below:

$ java –version

If OpenJDK installed you will get output like below:

Install OpenJDK 11 JRE

To run the java application with the latest Java Runtime Environment, you should install OpenJDK 11 JRE by using the following command:

$ sudo yum install java-11-openjdk

Oracle Java Installation

First, you should be aware of the Oracle Java Licence; it is free only for non-commercial use of the software like development and personal use.

You can download Oracle Java from the official website. You should download Oracle Java .rpm packages from the Java SE Downloads page. To download Oracle Java, you have to register on the oracle site.

After downloading .rpm package for Oracle Java, You can install it on CentOS 7 by using the following command:

$ sudo yum localinstall jre-8u221-linux-x64.rpm

To execute above command first need to download java from official website and use the same rpm file in localinstall command as shown above.

Java default version Setup

If you have installed multiple Java into your CentOS 7 machine, you can check the default version of Java by checking the version, as shown below:

$ java -version

The output of the above command will look like below image:

You can change the default Java version by using update-alternatives command, as shown below:

$ sudo alternatives --config java

You will get the list of all installed Java version on your CentOS 7 machine, Enter the number of the version you want to use as a default and press Enter button.

Java Uninstall

If you want to remove Java package from your CentOS system, you can uninstall it like any other application with yum package manager.

To uninstall the java-1.8.0-openjdk-devel package from your CentOS machine, you can use below command:

$ sudo yum removejava-1.8.0-openjdk-devel

Conclusion

Now you have learned how to install Java on CentOS 7 operating system. You get java installation instruction for both OpenJDK and Oracle Java.

- Advertisement -
- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subscribe to our newsletter

To be updated with all the latest news, offers and special announcements.

Latest article

How to Setup a Firewall with UFW on Ubuntu 20.04

Nowadays, a Firewall is an essential utility and property of any system for security; by default Ubuntu Operating system having a firewall...

How to Install Ruby on Ubuntu 20.04 Linux

Nowadays, Ruby is the most popular language, especially for SaaS application development. It has a perfect and elegant syntax structure, and it...

How to Install Eclipse IDE on Ubuntu 20.04 Linux

Eclipse is the most famous and widely used Java integrated development environment (IDE). It supports many plugins to enhance the capabilities to...

The 30 most useful Linux commands

This article will introduce some practical and common Linux or Unix command , which is the Linux system administrators normally use the command . This article is not a...

How to Reset the MySQL Root Password

Do you want to reset the MySQL root password? Sometimes we forget the root password and not able to log in on...