1. Check if Java is installed (mostly two Openjava)
Java-version
2. Uninstall the Openjava, you need to uninstall two, the package name after the replacement of a good
RPM-E--nodeps java-1.xx.0-openjdk-xxx
3. Download the RPM package from Oracle official website, you can also download the tar package, but the personal feeling RPM package unloading and installation are fast, there is a need to leave a message;
Http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
4. Use XFTP5, put in the virtual machine, can also be downloaded in other ways (such as: wget) or transmission, transmission is recommended to use the root account, because it may cause the problem of permissions, here I am my own virtual machine, storage location can be arbitrary;
5. Unzip the installation RPM package
RPM-IVH jdk-8u171-linux-x64.rpm
6. Find the default path for the system to install automatically, the main purpose is to configure environment variables
Find/-name ' java.* '
This means to find files that meet the ' java.* ' criteria in the root directory;
Enter the file directory,
Pwd
Copy the file directory
7. Configure the environment variables; Here you only need to change a bit, the path behind the java_home and replace it with your own Java installation path, java_home mainly refers to the Java file Bin directory in front of the path;
Vim/etc/profile
Insert at the end, as follows:
Export JAVA_HOME=/USR/JAVA/JDK1.8.0_171-AMD64
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH
Save exit
: Wq
Execution configuration takes effect
Source/etc/profile
8. Check again, or you can come to a HelloWorld
Java-version
Java
Javac
9. Questions, notes save updated environment variables, the above command basically no impact, can be compiled, can be executed; do not know what the reason;
CentOS-7 system, installation of Java and configuration of environment variables