Java is a popular programming language used for developing web applications, desktop applications, and mobile applications. To run Java applications on your CentOS 6 or CentOS 7 system, you need to install Java Development Kit (JDK). In this guide, we will outline the steps to install JDK 8u45 on CentOS 6 and CentOS 7.
Step 1: Update the System
Before installing JDK, you need to update your system by running the following command:
sudo yum update
Step 2: Download JDK 8u45
Next, you need to download JDK 8u45 from the Oracle website. You can do this by running the following command:
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz"
Step 3: Install JDK 8u45
Once you have downloaded JDK 8u45, you can proceed with the installation by running the following commands:
sudo mkdir -p /usr/java/ sudo tar -zxvf jdk-8u45-linux-x64.tar.gz -C /usr/java/
Step 4: Set Environment Variables
After the installation is complete, you need to set the environment variables for Java. You can do this by running the following commands:
For CentOS 6:
sudo echo "export JAVA_HOME=/usr/java/jdk1.8.0_45" >> /etc/bashrc sudo echo "export PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/bashrc source /etc/bashrc
For CentOS 7:
sudo echo "export JAVA_HOME=/usr/java/jdk1.8.0_45" >> /etc/profile sudo echo "export PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/profile source /etc/profile
Step 5: Verify JDK Installation
Finally, you can verify if JDK is installed correctly by running the following command:
If the installation is successful, you should see the version of JDK installed on your system.
# java -version java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
- yum – Yellowdog Updater Modified, a package manager for CentOS
- wget – A command-line tool used to download files from the internet
- tar – A command-line tool used to compress and extract files and directories
- echo – A command-line tool used to print text to the terminal
In this guide, we have outlined the steps to install JDK 8u45 on CentOS 6 and CentOS 7. By following these steps, you can now run Java applications on your system. If you encounter any issues during the installation process, feel free to comment or suggest improvements.