1. First log in to Linux and switch to the root user
sudo passwd root Change the password of the root user
2.su root switch to root user
3. Create a java installation directory in the usr directory
cd usr ; mkdir java
4. Copy jdk-8u60-linux-x64.tar.gz to the java directory
cp /mnt/hgfs/linux/jdk-8u60-linux-x64.tar.gz /usr/java/
5. Unzip the jdk to the current directory
tar -zxvf jdk-8u60-linux-x64.tar.gc
get the folder jdk1.8.0_60
6. After installation, create a link for him to save directory length
ln -s /usr/java/jdk1.8.0_60/ /usr/jdk
7. Edit the configuration file, configure environment variables, the configuration file can only be modified under the root user, other users have no permission
vim /etc/profile
add the following: JAVA_HOME according to the actual directory
JAVA_HOME=/usr/java/jdk1.8.0_60
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
8. Restart the machine or execute the command
sudo shutdown -r now
9. Check the installation
java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) Client VM (build 25.60-b23, mixed mode)