Home >Operation and Maintenance >Linux Operation and Maintenance >How to configure the jdk environment in Linux system

How to configure the jdk environment in Linux system

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBforward
2023-05-12 09:31:057057browse

The following steps are to deploy the jdk environment in the linux system

1. Download the jdk installation package

How to configure the jdk environment in Linux system

How to configure the jdk environment in Linux system

2. Create a new installation jdk folder (/usr/local/java/jdk)

cd /usr/local                
mkdir /usr/local/java        local目录下新建java目录
cd /usr/local/java           
mkdir /usr/local/java/jdk    新建jdk目录
cd /usr/local/java/jdk

3. Upload the jdk installation package to linux

How to configure the jdk environment in Linux system

4. Decompress the jdk installation package

Decompression format: tar zxvf compressed package name

You can enter only one initial letter for the name after it, and then use the Tab button to automatically complete the full file name

eg: tar zxvf j
 tar zxvf jdk-15_linux-x64_bin.tar.gz   解压
 rm -f jdk-15_linux-x64_bin.tar.gz    删除压缩包

5. Start configuring environment variables

5.1 Locate the configuration file

cd /usr/local/etc  
find -name profile  搜索文件名为“profile”的文件
vim /etc/profile    进去profile文件

5.2 Enter the I key to switch to input mode.

How to configure the jdk environment in Linux system

5.3 Please copy the following code content and paste it into the profile file as shown (enter in front of unset i)

export JAVA_HOME=/usr/local/java/jdk/jdk-15  ------ 自己安装jdk的路径
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

How to configure the jdk environment in Linux system

5.4 Save profile and exit.

Press Esc to exit insert mode, enter: wq to save and exit

  • :q! No matter edited or unedited, do not save and exit

  • :wq Save and exit

How to configure the jdk environment in Linux system

5.5 File modification effective command

source /etc/profile

6. Verify whether jdk is configured successfully

java -version

How to configure the jdk environment in Linux system

The above is the detailed content of How to configure the jdk environment in Linux system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete