First, download the JDK
: http://www.oracle.com/technetwork/java/javase/downloads/index.html
View Linxu number of system bits:getconf long_bit
According to the number of bits of the system, download the corresponding version, mine is 64-bit:
Second, unzip the JDK
Unzip the JDK file: (tar-xzf source file target directory), if the target directory does not have permissions, you can use root permissions
Tar-xzf jdk-8u45-linux-x64.tar.gz/usr/share/java/
Third, set environment variables
1. System-Level environment variables:/etc/profile
2. User-level environment variables:/home/User name/.bash_profile
Use the VI command to open:
Vi/etc/profile
Then press i to enter insert mode, add at the end
Export java_home=/usr/share/java/ jdk1.8.0_45
Export path= $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/toos.jar
Then press "ESC" key, then enter : Wq , then return, save exit.
Then execute the following command to make the environment variable effective
Source/etc/profile
Iv. Test whether the JDK is in effect
Java-version
If the following is displayed, the installation is successful:
Java Version "1.8.0_45"
Installing JDK under Linux