Install JDK and centosjdk in CentOS 7
1. Uninstall the built-in openjdk
1. Run the following command to query the built-in jdk:
rpm -qa | grep java
The existing jdk in the system is listed. If the jdk exists, uninstall it. If the jdk does not exist, install it directly.
2. Run the following command to uninstall:
Rpm-e -- nodeps jdk name
Jdk installation can be performed after uninstallation. The query and uninstallation operations are as follows:
Ii. jdk Installation
1. Download jdk and upload it to the/usr/java directory.
JDK 7 is: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html select the corresponding linux version, download rpm file. Here the jdk-7u79-linux-x64.rpm is selected. And upload it to the/urs/java directory of Linux (create if the java directory does not exist ).
2. Unzip and install
Run the following command to decompress the package:
Rpm-ivh rpm file name
Shows the running result.
3. Configure the profile file
Run the following command:
vi /etc/profile
Add the following content to the end of the profile file and keep it
export JAVA_HOME=/usr/java/jdk1.7.0_79export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport PATH=$PATH:$JAVA_HOME/bin
/Usr/java/jdk1.7.0 _ 79 indicates the jdk path.
Run the following command to make the configuration take effect.
source /etc/profile
Run the following command to check whether jdk is successfully installed:
java -version
The related operation diagram is as follows: