how to install java runtime environment on centos 7

w‮tual.ww‬turi.com
how to install java runtime environment on centos 7

To install the Java Runtime Environment (JRE) on CentOS 7, you can follow these steps:

  1. Install the java-1.8.0-openjdk package using yum, the package manager for CentOS:
sudo yum install java-1.8.0-openjdk

This will install the OpenJDK 8 JRE, which is the open-source version of Java.

  1. Set the JAVA_HOME environment variable to the path of the JRE installation. To do this, open the /etc/environment file using a text editor, such as vi or nano, and add the following line:
JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk"

Save the file and exit the text editor. To apply the changes, run the following command:

source /etc/environment
  1. Verify that the JRE is installed and the JAVA_HOME environment variable is set by running the following command:
java -version

This command should print the version number of the OpenJDK 8 JRE.

You can also install the Oracle Java JRE, which is the proprietary version of Java, by following a similar process. To install Oracle Java 8, you will need to add the Oracle Java PPA (personal package archive) to your system's package sources and install the oracle-java8-installer package using yum. You can find instructions on how to do this on the Oracle website (https://www.oracle.com/java/technologies/javase-downloads.html).

Keep in mind that Oracle Java 8 is no longer supported by Oracle, and it is recommended to use a newer version of Java, such as Java 11 or Java 15. To install a newer version of Java, you can follow a similar process, but replace java-1.8.0-openjdk with the appropriate package name.

Created Time:2017-11-01 20:42:56  Author:lautturi