Ubuntu 16.04 install jdk1.8 steps

JDK version: jdk1.8.0_121

1. Download the JDK file jdk-8u121-linux-x64.tar.gz from the official website

2. Create a directory as the JDK installation directory, open Home My directory is java

3. Move the file to /java

sudo mv jdk-8u121-linux-x64.tar.gz /java in the directory

4. Unzip the file

tar -zxvf jdk-8u121-linux-x64.tar.gz

5. Configure the environment variable

sudo gedit /etc/environment

Add the following configuration at the end (The path after JAVA_HOME is the jdk file location)

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/ usr/local/games:$JAVA_HOME/bin"
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export JAVA_HOME=/java/jdk1.8.0_121

Save and close after modification, and enter the following command to make the environment variable Immediately effective

source /etc/environment

6. Enter java -version, the JDK version description will be displayed. Congratulations, the environment variable configuration is correct

. 7. But it is not over yet. According to the articles written by others, it is found that it cannot be used after each restart, so Also need to configure environment variables for all users

sudo gedit /etc/profile

Add the following at the end of the file:

#set Java environment

export JAVA_HOME=/dengyang/jdk1.8.0_56
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib: $CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

8. Similarly, you need to use the command to make the environment variable take effect immediately

source /etc/profile

9. Restart the computer, you can enter the system normally, and the java -version command is valid

Guess you like

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