CentOS7 comes with jdk1.8
View the current system jdk version: java -version
List the packages that match the installed java: yum list installed | grep java
Uninstall the installed jdk:
yum -y remove java-1.7.0-openjdk*
yum -y remove java-1.8.0-openjdk*
There are many ways to install the JDK, I will just decompress the JDK package manually
You can directly use XSHELL to connect to the virtual machine, enter the directory where you want to store the JDK, and then drag the tar package directly from the windows desktop, or use the command rz -e
When decompressing, use the tar command, and the following parameters must not be less, try not to use tar -xf, so that the decompression process will not be displayed, and the decompression error will not be reported, I just because the tar package is damaged, the decompression error causes the jdk to continue Bad match!
It is recommended to use tar -zxvf
vim /etc/profile Edit profile file and input: vim /etc/profile
Enter the following:
export JAVA_HOME=/home/sun/software/jdk1.8.0_221 --- The specific path is configured according to the path where you installed the JDK
export CLASSPATH=.:
export PATH=
Notes:
JAVA_HOME indicates the JDK installation path, which is the path selected during the installation. This path includes lib, bin, jre and other folders (tomcat, Eclipse need to rely on this variable).
CLASSPATH is the path of java loading class (class or lib), only the class is in the classpath, the java command can recognize it, set: .:
PATH enables the system to recognize java commands in any path, set to:
Special attention: there is no sign at the end of the environment variable value, and the different values are separated by: (in windows, use;).
Make the configuration file effective: source /etc/profile
Verify the installation: java -version
Recommended Posts