Install jdk-8u111-linux-x64.tar.gz under Ubuntu16.04 and configure the Java ring

Under windows, go to the official website to download jdk-8u111-linux-x64.tar.gz: 
   
  image_1b6fvereu183d6rv1dlk1qm1n9n9.png-218.5kB
   
  upload the downloaded jdk to the ubuntu server through ftp, and configure VSFTPD, see "Configuring VSFTPD under Ubuntu16.04" , and here I use the Xftp 5 is used as an FTP client under Windows. After the upload is complete, go to the file directory and use the following command to unzip it:

sudo tar -zxvf jdk-8u111-linux-x64.tar.gz
  • 1

  After the decompression is successful, you can see that there is an additional folder jdk1.8.0_111 in this directory: 
   
  image_1b6fvt2n711ne15a41o2mm3iqlkm.png-18kB 
   
  first create a new folder java under /usr, and then move the folder jdk1.8.0_111 to the directory /usr/java:

sudo mv jdk1.8.0_111 /usr/java/
  • 1

  Enter the directory /usr/java to view the folder, indicating that the move is successful: 
   
  image_1b6g0t0p3151q1itr6seabv15h713.png-20.4kB 
   
  Now configure the system environment variables, and now we configure it under the global configuration file /etc/profile, that is, configure the Java environment for all users, and use the vi command to edit /etc /profile file:

sudo vi /etc/profile
  • 1

  Add four pieces of configuration information at the bottom of the file:

export JAVA_HOME=/usr/java/jdk1.8.0_111
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:%{JAVA_HOME}/lib:%{JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
  • 1
  • 2
  • 3
  • 4

  Among them, JAVA_HOME is specified as your JDK installation directory. In addition, in linux, it is separated by colons, which is different from the use of semicolons in windows. 
  After editing, save and exit, execute the command:

source /etc/profile
  • 1

  To add: The source command, also known as the "dot command", is a dot symbol (.). It is typically used to re-execute a just-modified initialization file to take effect immediately without having to log out and back in. At the same time, some commands can be made into a file, and it can be executed automatically and sequentially. It can execute the content of this file as a shell. 
  Now you can execute the javac command and the java -version command for testing: 
   
  image_1b6g5arnirdr18ds17o7ofsuf1g.png-187.4kB
   
  if the above information is output, it proves that the Java environment has been successfully configured.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325649755&siteId=291194637