Environment: ubuntu16.04 vmware virtual machine environment
Jdk download from Oracle's official website, jdk-8u231-linux-x64.tar.gz
(1) to / opt the directory
sudo cp jdk-8u231-linux-x64.tar.gz /opt
Create a java directory (3) / opt directory, change the permissions for all current users
sudo mkdir java sudo chown Liko java sudo chgrp Liko java
(4) The installation extracted the java directory
tar -zxvf jdk-8u231-linux-x64.tar.gz -C /opt/java
(5) configure the environment variables
to modify / etc / profile file
and add the following information thereafter:
#set java environment export JAVA_HOME=/opt/java/jdk1.8.0_231 export PATH=${JAVA_HOME}/bin:${PATH}
(6) the entry into force of java environment
to perform source / etc / profile at this time to perform echo $ JAVA_HOME can already see the path just set up
At this point the installation is complete, pleasant to javac, java -version it!