To install the Java SDK on a CentOS system using the yum
command, follow these steps:
- Import the Oracle GPG key by running the following command:
sudo rpm --import https://yum.oracle.com/RPM-GPG-KEY-oracle-ol7
- Create a file called
/etc/yum.repos.d/java.repo
with the following content:
[ol7_developer_EPEL]
name=Oracle Linux $releasever Developer (EPEL)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/developer/EPEL/x86_64/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
- Update the package index by running
sudo yum update
. - Install the Java SDK by running the following command:
sudo yum install java-1.8.0-openjdk
- Verify the installation by checking the version of Java installed by running the following command:
java -version
That’s it! You have successfully installed the Java SDK on your CentOS system using the yum
command.