Java is a very famous, general-purpose programming language that is used for creating applications that run on mobile devices as well as computers. It can create applications that can run on a single system as well as can be distributed among servers & clients in a network. In this tutorial, we will learn to install JAVA on CentOS/RHEL & Redhat hat based on other Linux operating systems.
Recommended Read: How to change timezone in Linux
Also Read: Learn to use KILL COMMAND in Linux
Before we learn about java installation, we must know the types of java available to install. There are two different types of java versions we can install. Two versions being,
JAVA JRE (Java Run Time Environment) – JRE is used when you only need to run java based applications.
JAVA JDK (Java Development Kit) – is used for developing Java-based applications. It included JRE, debugging tool & some other libraries.
Moreover, there are two different java versions that you install OpenJDK & Oracle java.
OpenJDK installation
We will start by installing the java 8 on our systems first & then will also discuss other java versions also. Open terminal & enter the following command to install Java 8,
# yum install java-1.8.0-openjdk-devel
This will install JDK on the system, to only install JRE on the system, use
# yum install java-1.8.0-openjdk
Java 8 is still one of the most widely used java versions but if you are looking at the latest java version with long term support, then you should be using Java 11. Let’s learn how to install this on our system,
# yum install java-11-openjdk-devel
To install JRE on the system, the command is
# yum install java-11-openjdk
Oracle Java installation
Oracle java packages are not available for installation on operating system default repositories & can only be installed using the rpm packages that are available on the official website’s DOWNLOAD PAGE. Once you download the rpm package, then you can install it similarly as you would any other rpm package, either using yum command or rpm command,
# yum localinstall ORACLE_JAVA_PACKAGE.rpm
That’s it, java is now installed on the system. The next part is configuring the default java for the systems as you might have more than one java version installed on the system.
Configuring default Java
Command to configure the default java is,
# alternatives –config java
Then you should get the java versions installed on the system, type the number mentioned against the java version & press enter to make it the default versions. This will change the java versions to one that you want. Please do let us know if you have questions, queries or suggestions using the comment box below.