Configuring JDK environment variables (Ubuntu system) in Linux virtual machines

  1. First Xshell file transfer via virtual machine you want to upload your jdk, as shown in Figure :( need to install the machine Xftp: link: https://pan.baidu.com/s/1sWHmywZ2C6V2n4aa1FqqFg extraction code: y67j)
  2. Open xftp, to choose their own jdk version in the left side of the File Transfer page, double-click or right-transmission to the right / root folder below the new soft

     

  3. Into the / root / soft directory xshell the next, performing tar -xzvf jdk-8u152-linux-x64.tar.gz, the decompression jdk
  4. Execute mkdir / usr / local / java command to create java folder
  5. Performing mv jdk1.8.0_152 / / usr / local / java / jdk be decompressed to cut folder jav
  6. Performing vi / etc / environment commands, editing environment variables (not the first to enter the edit mode, press the "i" key to enter the edit mode), add the following code in the environment variables:
    export JAVA_HOME=/usr/local/java/jdk1.8.0_152
    export JRE_HOME=/user/local/java/jdk1.8.0_152/jre
    export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

    (JDK version, or pay attention to the path change)

  7. Rearrangement user variables, perform vi / etc / profile command (shift + insert paste using the following)
    export JAVA_HOME=/usr/local/java/jdk1.8.0_152
    export JRE_HOME=/user/local/java/jdk1.8.0_152/jre
    export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
    export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$Home/bin

    The code in the following positions:

  8. After the paste is completed, press esc to exit edit mode, press the ":" key to enter wq !, Force Quit command to save

  9. After completion of editing system variables and user variables, we need to become effective operation variables need to do source / etc / profile command the variables to take effect
  10. Use java -version to see if the configuration variables to take effect, the following picture appears, that is success

Guess you like

Origin www.cnblogs.com/LiBaiWen/p/11014813.html