[Linux] Linux configuration Java environment

1 Download JDK

Official website
Official website
or
Baidu network disk (extraction code: y7n0)

2 Unzip the installation package

Check the jvm directory, if there is no need to create one

cd /usr/lib
ls

jvm
Command to create jvm directory

mkdir /usr/lib/jvm

Switch to the location of the installation package, unzip the installation package to the jvm directory

cd ~/Downloads/
sudo tar -zxvf ./jdk-8u271-linux-x64.tar.gz -C /usr/lib/jvm

After decompression, switch to the jvm directory and you can see the jdk directory:
jdk

3 Set environment variables

vim ~/.bashrc

Add the following environment:

export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_271
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

Make it effective immediately after saving and exiting:

source ~/.bashrc

4 Check if the installation is successful

java -version

If the following version information appears, the installation is successful
an examination

Guess you like

Origin blog.csdn.net/Tiezhu_Wang/article/details/113822949
Recommended