CentOS7 comes jdk1.8
View the current system jdk version: the Java -version
Java list matches installed packages: yum List Installed | grep java
Uninstall jdk installation:
yum -y remove java-1.7.0-openjdk*
yum -y remove java-1.8.0-openjdk*
Many ways to install the JDK, I say to manually extract the JDK archive
XSHELL can be used directly connect the virtual machine, enter want to store the JDK directory and from the windows desktop directly into the tar package drag, you can also use the command rz -e
Now I will talk about my stepped pit! ! !
When extracting the tar command, with the latter parameter must not be less, try not to use tar -xf , this does not show the decompression process, and extract the error does not report it, because I tar the package is damaged, unpack error, leading to back up jdk with bad!
We recommend using tar -zxvf
Then configure the environment variables:
vim / etc / profile edit profile file input: vim / etc / profile
Enter the following:
export JAVA_HOME = / home / sun / software / jdk1.8.0_221 --- particular route path is configured according to their JDK is installed
export CLASSPATH =:. $ JAVA_HOME / jre / lib / rt.jar: $ JAVA_HOME / lib / dt. JAR: $ the JAVA_HOME / lib / the tools.jar
Export the PATH the PATH = $: $ the JAVA_HOME / bin
Comment:
JAVA_HOME specify JDK installation path, that is, when just installed a selected path, this path includes lib, bin, jre and other folders (tomcat, Eclipse runs need to rely on this variable).
CLASSPATH of loading java class (class or lib) paths, only class in the classpath, java command can identify, provided:.: $ JAVA_HOME / lib /CLASSPATH variable values. Represents the current directory
PATH so that the system can recognize at any path java command, to: $ JAVA_HOME / bin: $ JRE_HOME
Special attention: the environment variable value is not the end of any symbol, with different values: spaced (windows with;).
The configuration file to take effect: Source / etc / Profile
Verify that the installation: the Java -version