Table of contents
1. Check whether the java (jdk) environment is installed under linux
You can use the following five commands to check whether the java environment is installed in the Linux system:
1, java -version
2, which java
3, rpm -qa |grep java
4, echo $PATH
5, find / -name java
2. Check the operating system version of linux
Used to select the corresponding jdk version
Command: uname -a
3. Download jdk
Official website address: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Here I downloaded
4. Create a new java folder for installing jdk
// 进入到/usr/local
cd /usr/local
// 创建java文件夹
mkdir java
// 查看当前目录下文件
ls
//进入java文件夹目录下
cd /java
5. Upload the downloaded jdk compressed package to the linux server
Upload file command:
rz
Decompression command:tar -zxvf 上传的jdk压缩包名
6. Configure environment variables
- open configuration file
vim /etc/profile
- append at the end of the file
JAVA_HOME=/usr/local/java/jdk文件名
CLASSPATH=%JAVA_HOME%/lib:%JAVA_HOME%/jre/lib
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH CLASSPATH JAVA_HOME
3. Then press esc
to exit edit mode, enter 冒号
, enter wq
to save and exit
4. Make the configuration file take effect: source /etc/profile
5. Check whether the installation is successful:java -version