[linux] install java environment

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

insert image description here

3. Download jdk

Official website address: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Here I downloaded
insert image description here

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压缩包名
insert image description here

6. Configure environment variables

  1. open configuration filevim /etc/profile
  2. 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

insert image description here

insert image description here
3. Then press escto exit edit mode, enter 冒号, enter wqto save and exit
insert image description here
4. Make the configuration file take effect: source /etc/profile
5. Check whether the installation is successful:java -version
insert image description here

Guess you like

Origin blog.csdn.net/qq_43622777/article/details/130059775