How to Install Java 8 on CentOS 8

Java is a widely used object-oriented programming language and software platform that runs on billions of devices, including notebook computers, mobile devices, gaming consoles, medical devices, and many others. The rules and syntax of Java are based on the C and C++ languages.

Developers use Java to construct applications in laptops, data centres, game consoles, scientific supercomputers, cell phones, and other devices. Java is the world’s third most popular programming language, after Python and C – according to the TIOBE index, which evaluates programming language popularity.

Install java 8 on CentOS 8; Through this tutorial, we will learn how to install java 8 on CentOS 8.

How to Install Java 8 on CentOS 8

Follow the following steps to install java 8 on CentOS 8:

  • Step 1 – Install Java 8
  • Step 2 – Verify Java Installation
  • Step 3 – Set Java Environment
  • Step 4 – Activate Java Environment
  • Step 5 – Test the Variables
  • Step 6 – Create a simple Java Application
  • Step 7 – Compile Java Source Code

Step 1 – Install Java 8

First of all, open the terminal or command line and execute the following command into it to install java 8 on centOS 8:

sudo yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel

Step 2 – Verify Java Installation

Once the java installation is completed, then execute the following command on the command line or terminal to check the version to validate the installation of Java 8 on CentOS 8:

java -version

Step 3 – Set Java Environment

Then execute the following command on the command line or terminal to set the java environment:

cat <

Step 4 – Activate Java Environment

Active java environment by executing the following command on the command line or terminal to activate the java environment:

source /etc/profile.d/java8.sh

Step 5 – Test the Variables

Then test the variables by executing the following command on command line or terminal:

echo $JAVA_HOME
/usr/lib/jvm/jre-openjdk

echo $PATH
/home/rocky/.local/bin:/home/rocky/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/lib/jvm/jre-openjdk/bin

echo $CLASSPATH
.:/usr/lib/jvm/jre-openjdk/jre/lib:/usr/lib/jvm/jre-openjdk/lib:/usr/lib/jvm/jre-openjdk/lib/tools.jar

Step 6 – Create a simple Java Application

Then create a simple Java application to see Java 8 working on CentOS 8:

cat > HelloWorld.java <

Step 7 – Compile Java Source Code

Then execute the following command on command line or terminal to compile java code:

javac HelloWorld.java

Conclusion

Install java 8 on CentOS 8; Through this tutorial, we have learned how to install java 8 on CentOS 8.

Images mentioned above related to CentOS,Java are either copyright property of respective image owners.

Rabins Sharma Lamichhane

Rabins Sharma Lamichhane is senior ICT professional who talks about #it, #cloud, #servers, #software, and #innovation. Rabins is also the first initiator of Digital Nepal. Facebook: rabinsxp Instagram: rabinsxp

Leave a Reply

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