1. Log in with the root user system, if the system already has other versions of the JDK, you can uninstall the relevant software package, command:
RPM-E--nodeps Jdkname
Where jdkname can not include character segments for version information, you can view them by using the following command:
Rpm-qa | grep JDK
2. Download the jdk1.8. rpm file from the Oracle website, address if http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.rpm? AUTHPARAM=1421409865_906DD11E2CABEF6E49C0A4E4B1A92B3A, the command is:
cd/user/local--first enter the directory where the package is saved
wget http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.rpm? authparam=1421409865_906dd11e2cabef6e49c0a4e4b1a92b3a
After downloading, you can use the LS command to see the download to the file name jdk-8u25-linux-x64.rpm? AUTHPARAM=1421409865_906DD11E2CABEF6E49C0A4E4B1A92B3A, can be renamed before installation:
MV jdk-8u25-linux-x64.rpm? AUTHPARAM=1421409865_906DD11E2CABEF6E49C0A4E4B1A92B3A jdk-8u25-linux-x64.rpm
3. Install JDK:
RPM-IVH jdk-8u25-linux-x64.rpm
The default path for installation is/usr/java
You can then use the java,javac,java-version command to view the relevant information
4. Configure Environment variables
To edit a configuration file with Vim:
Vim/etc/profile
Press I into insert mode, append at end
Java_home=/usr/java/jdk1.8.0_25
Jre_home=/usr/java/jdk1.8.0_25/jre
Path= $PATH: $JAVA _home/bin: $JRE _home/bin
Classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/lib
Export Java_home jre_home PATH CLASSPATH
Press ESC to exit Insert mode, and then: Wq Save the changes and exit, and then use the following command to make the configuration effective:
Source/etc/profile
5. After this installation is configured, you can view path and java_home:
Echo $PATH
Echo $JAVA _home