Complete steps to install JDK environment on Linux system


1. Select the jdk version installation package you need

Access oracle official website , click on the navigation bar Products's , select Software in the Java , find Download Java now and click. Select the jdk version you need, click ** JDK Download ** (here, select Java SE 11 (LTS)), select the package you need, and check I reviewed and accept the Oracle Technology Network License Agreement in the pop-up window for Oracle Java SE , click the button that turns green below, and log in if you need to log in. After the login is successful, it will be downloaded automatically.
After the download is successful, transfer the installation package scp ./Users/tinghs/Downloads/jdk-11.0.10_linux-x64_bin.tar.gz [email protected]:/root/softwareto the server through the command line .


2. Unzip the jdk installation package

Run the following command, you can modify the installation path and jdk installation package name according to your needs.

[root@tinghs software]# mkdir -p /usr/local/jdk
[root@tinghs software]# tar -zxvf jdk-11.0.10_linux-x64_bin.tar.gz -C /usr/local/jdk

3. Set environment variables

Run the command below to set environment variables.

[root@tinghs software]# vi /etc/profile

Use Shift + Gto reach the end of the file, click I, add the following configuration, and modify the path of JAVA_HOME according to the actual situation:

export JAVA_HOME=/usr/local/jdk/jdk-11.0.10/  
export JRE_HOME=${JAVA_HOME}
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  
export PATH=${JAVA_HOME}/bin:$PATH

Use to Escend editing, use to :qwsave and exit the file.


4. Execute the profile file

Execute the profile file to make the environment variables take effect.

[root@tinghs software]# source /etc/profile

5. Test whether the java command is running normally

[root@tinghs software]# java -version

If the java version appears, it means that the jdk environment is successfully configured.


Guess you like

Origin blog.csdn.net/baidu_41847368/article/details/114301332