Linux environment installation and use jdk detailed explanation

01-Install JDK

 

1.1 Download jdk compressed package

    download link:
    After the download is complete, upload it to the server

# 1. Unzip the JDK to the specified directory

tar -zxvf jdk-8u171-linux-x64.tar.gz -C /usr/
Note: The -C parameter is to put the JDK decompressed file into the usr directory

# 2. Enter the jdk decompression directory to view

cd /usr/jdk1.8.0_171/

# 3. View detailed information

[root@localhost jdk1.8.0_171]# ls
bin db javafx-src.zip lib man release THIRDPARTYLICENSEREADME-JAVAFX.txt
COPYRIGHT include jre LICENSE README.html src.zip THIRDPARTYLICENSEREADME.txt

# 4. Configure environment variables

vi /etc/profile

# 5. Add the following configuration at the end of the file

export JAVA_HOME=/usr/jdk1.8.0_171
export PATH=$PATH:$JAVA_HOME/bin

# 6. Load configuration takes effect

source /etc/profile load configuration takes effect
reboot restart the system
Note: You can choose any one of the above two options. The source can take effect immediately without restarting. In some cases, when the source cannot take effect, you can try restarting it.

# 7. Test environment variables

java
javac
java -version

1.2 rpm package installation

# 1. Install jdk

[root@localhost ~]# rpm -ivh jdk-8u171-linux-x64.rpm
Preparing... ################################### [100%]
Upgrading/installing...
1:jdk1.8-2000:1.8.0_171-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...

# 2. Search the default installation location

[root@localhost ~]# find / -name "java"
/usr/java/jdk1.8.0_171-amd64/bin/java
/usr/java/jdk1.8.0_171-amd64/jre/bin/java

# 3. Configure environment variables

vi /etc/profile

# 4. Add the following configuration at the end of the file

export JAVA_HOME=/usr/java/jdk1.8.0_171-amd64/
export PATH=$PATH:$JAVA_HOME/bin

# 5. Load configuration takes effect

source /etc/profile load configuration takes effect
reboot restart the system
Note: You can choose any one of the above two options. The source can take effect immediately without restarting. In some cases, when the source cannot take effect, you can try restarting it.

# 6. Test environment variables

java
javac
java -version

Continually updated!

 

Guess you like

Origin blog.csdn.net/weixin_51689532/article/details/130634957