Linux jdk1.8 environment installation and configuration and Maven installation and configuration

One, jdk1.8 environment installation

1. Official website download: https://www.oracle.com/java/technologies/downloads/#java8

insert image description here

2. Create a new java folder under the usr folder

[root@mylinux1 usr]# mkdir java

3. After the decompression is completed, transfer the jdk file to the java directory

insert image description here

[root@mylinux1 java]# ls
jdk1.8.0_361

2. Configuration environment (emphasis)

[root@mylinux1 java]# vim /etc/profile

1. Press i to edit, add the following information at the end

export JAVA_HOME=/usr/java/jdk1.8.0_361
export JRE_HOME=${
    
    JAVA_HOME}/jre
export CLASSPATH=.:${
    
    JAVA_HOME}/lib:${
    
    JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${
    
    JAVA_HOME}/bin:${
    
    JRE_HOME}/bin
export PATH=$PATH:${
    
    JAVA_PATH}

2. Press esc to exit editing, then press shift + : to display, then press wq! to save and exit

3. Execute the following command to refresh and make the configuration file take effect

[root@mylinux1 java]# source /etc/profile

4. Check whether the configuration information is modified successfully

[root@mylinux1 java]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/apache-maven-3.9.1/bin:/root/bin:/usr/local/apache-maven-3.9.1/bin:/usr/java/jdk1.8.0_361/bin:/usr/java/jdk1.8.0_361/jre/bin

5. Enter java -version to display information

[root@mylinux1 java]# java -version
java version "1.8.0_361"
Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.361-b09, mixed mode)

3. If the following error occurs

[root@mylinux1 java]# java -version
-bash: /usr/java/jdk1.8.0_361/bin/java: 权限不够

1. Solution:

[root@mylinux1 jdk1.8.0_361]# chmod 777 /usr/java/jdk1.8.0_361/bin/java

4. Uninstall

1. First check whether JDK is installed

[root@mylinux1 java]# java -version

2. View the installation path

[root@mylinux1 java]# which java
/usr/java/jdk1.8.0_361/bin/java

3. Uninstall: delete the folder above the bin directory

[root@mylinux1 java]# rm -rf /usr/java/jdk1.8.0_361

4. Delete the configuration of environment variables and remove the previously configured information

[root@mylinux1 java]# vim /etc/profile

Five, Maven environment installation

1. Download address: https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.9.1/binaries/

insert image description here

[root@mylinux1 local]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.9.1/binaries/apache-maven-3.9.1-bin.zip

2. Put the decompressed package in the /usr/local directory

[root@mylinux1 local]# ls
apache-maven-3.9.1  bin  etc  games  include  lib  lib64  libexec  sbin  share  src

3. Enter /etc/profile, edit the following command

[root@mylinux1 usr]# vim /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.9.1
export PATH=$PATH:$MAVEN_HOME/bin

insert image description here

4. Let resources take effect

[root@mylinux1 usr]# source /etc/profile

5. Check whether the configuration is normal

[root@mylinux1 usr]# mvn -v
Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Maven home: /usr/local/apache-maven-3.9.1
Java version: 1.8.0_361, vendor: Oracle Corporation, runtime: /usr/java/jdk1.8.0_361/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.el7.x86_64", arch: "amd64", family: "unix"

Guess you like

Origin blog.csdn.net/YZL40514131/article/details/130080838