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

WBOY
Release: 2023-05-12 09:31:05
forward
7001 people have browsed it

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
Copy after login

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
Copy after login
 tar zxvf jdk-15_linux-x64_bin.tar.gz   解压
Copy after login
 rm -f jdk-15_linux-x64_bin.tar.gz    删除压缩包
Copy after login

5. Start configuring environment variables

5.1 Locate the configuration file

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

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
Copy after login

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
Copy after login

6. Verify whether jdk is configured successfully

java -version
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template