The most convenient way is to directly copy other system jdk packages to use
1. Upload jdk1.8.0_102_20171101.tar.gz to the /usr/local directory of the server
2. Use the following command to unpack, and the jdk is deployed
gzip -cd jdk1.8.0_102_20171101.tar.gz | tar-xvf –
3. View the copied version of jdk
4. If you copy the jdk package directly, sometimes you need to configure the jdk environment variable
(1) Enter the jdk configuration directory
cd /etc
(2) Backup configuration files
cp profile 20180322_profile_bak
(3) Edit the configuration file profile
vi /etc/profile
Add the following parameters
export JAVA_HOME=/usr/local/jdk1.8.0_102
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
Note: /usr/local/jdk1.8.0_102 is the storage path of the copied jdk
(4) Load the variable just set
source /etc/profile
(5) Test whether the installation is successful
Enter java-version and then the version information of jdk will be displayed, etc.
Entering javac will display the command help of javac so that the jdk and environment variables are configured successfully