Java is one of the most popular programming languages for creating software and applications around the world. It is owned by Oracle, and more than 4 billion devices run on Java. The Java programming language and computing platform is a well-known, secure, stable, and robust language and technology platform with many integrated capabilities. Many popular tools are based on Java, such as Jenkins application which is used to set up CI/CD on the Linux operating systems (CentOS, Ubuntu).
Read Also: How to install Jenkins on Ubuntu 20.04
We need to install a Java package on the server or the local system to run the Java-based applications in the form of Java Runtime Environment (JRE). Java Runtime Environment is a collection of software components used to run Java applications.
In today’s tutorial, we will learn how to install and configure the multiple Java version on the CentOS 7 with simply steps.
Prerequisites
- Server or Local system with CentOS operating system.
- Access of Root user or another user with Sudo privileges.
Install Java OpenJDK
For the Java installation, follow the below steps one by one carefully.
- Install the necessary package for Java installation.
sudo yum install -y curl
Java 20
- Download the Java 20 package using the curl command in the terminal.
curl -O https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.rpm
- To install Java 20 run the following command.
rpm -ivh jdk-20_linux-x64_bin.rpm
Java 17
- Download the Java 17 package using the curl command in the terminal.
curl -O https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm
- To install Java 17 run the following command.
rpm -ivh jdk-17_linux-x64_bin.rpm
Verify Java OpenJDK Installation
Verify that Java is installed by using the below command.
java -version
You will get an output like this, after executing the above command,
Set the default Java version on CentOS 7
To set the default version of Java among multiple Java versions on the system, use the alternative command, as shown below.
sudo alternatives --config java
Now choose the Java Version which you want to set as default.
Uninstall Java
If you want to install the java package from the server. You can easily uninstall it as any other package with the help of the yum command.
For example, if you want to remove the open JDK Java 19 then run the following command.
yum remove jdk-19
To uninstall any other java package, then simply replace the jdk-19 with your Java package name.
Conclusion
In today’s tutorial, we installed multiple Java versions using the yum package on CentOS. We can manage multiple Java versions with the help of alternative environment variables on CentOS. If you guys have any questions or queries, then let me know in the comments section.
Leave a Reply
View Comments