8

How To Install Java 8 on CentOS 8 / RHEL 8 Linux

 3 years ago
source link: https://computingforgeeks.com/how-to-install-java-8-on-centos-rhel-8/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
How To Install Java 8 on CentOS 8

How can I install Java 8 on CentOS 8 / RHEL 8?. On Red Hat Enterprise Linux (RHEL) 8, two major versions of Java are available – Java 11 and Java 8. Our last article addressed the installation of Java 11 on CentOS / RHEL 8. In this article, I’ll cover the installation of Java 8, specifically, JDK (Java Development Kit) 8 on RHEL / CentOS 8.

You can check features of RHEL 8 and optionally how to install RHEL 8 if you’re a new user.

Install Java 8 on CentOS 8 / RHEL 8

To install JDK 8 on your CentOS 8 / RHEL 8 server or workstation machine, Use the following command.

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

Check version to validate installation of Java 8 on CentOS 8 / RHEL 8.

$ java -version
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)

 Set Java environment variables.

cat <<EOF | sudo tee /etc/profile.d/java8.sh
export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export PATH=\$PATH:\$JAVA_HOME/bin
export CLASSPATH=.:\$JAVA_HOME/jre/lib:\$JAVA_HOME/lib:\$JAVA_HOME/lib/tools.jar
EOF

Activate Java environment.

source /etc/profile.d/java8.sh

Create a simple Java application to see Java 8 working on RHEL / CentOS 8.

cat > HelloWorld.java <<EOF
public class HelloWorld {
	public static void main(String args[]) {
		System.out.println("Hello World");
	}
}
EOF

Compile your Java source code.

$ javac HelloWorld.java

This will create HelloWorld.class file, which is the bytecode embodiment of the source code. To run the HelloWorld.class file, use:

$ java HelloWorld
Hello World

You now have Java installed and configured on RHEL 8 / CentOS 8. Enjoy your development!!.

Video courses:

Want to Master Java Programming language, check:

Best Books for Learning Java Programming

For Java 11, use how to install Java 11 on RHEL / CentOS 8.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK