Centos7 installs 64-bit JDK1.8

Table of contents

1. Install using tar compressed package

Download JDK

Unzip JDK to local library

Unzip to local user directory

View execution results

Configure environment variables

Set soft link

Or set the system global environment variable

Verify installation results

2. Install using rpm package

Download rpm package

Install rpm package

Configure system environment variables

Verify installation

installation path


There are two common ways to install JDK on Centos7 systems:

1. Install using tar compressed package

Download JDK

Take the installation of jdk-8u181-linux-x64.tar.gz as an example. Although Oracle currently provides jdk1.8 for free download, users need to register an account on the official website first and log in before downloading. The steps are relatively cumbersome. , I downloaded and uploaded one for everyone’s convenience. The network disk link is: JDK1.8u181 installation package. If the link is invalid, please leave a message or send me a private message.

Unzip JDK to local library

Unzip to local user directory

tar xvf jdk-8u181-linux-x64.tar.gz -C /usr/local

View execution results

Configure environment variables

Set soft link

ln -s /usr/local/jdk1.8.0_181/bin/java /usr/local/bin/java

Or set the system global environment variable

Edit /etc/profile and add the following variables at the end

# export是把变量导出为全局变量,对所有用户生效
export JAVA_HOME=/usr/local/jdk1.8.0_181
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH

 If you want it to take effect immediately, execute the source or .command

. /etc/profile

Note: If both soft links and global variables are set in this example, when the terminal executes the java command, the global variable will be used instead of the soft link, because Linux executes the commands in the order in PATH by default.

Verify installation results

View version

java -version

The results are as follows

2. Install using rpm package

Download rpm package

Take the installation of oracle-j2sdk1.8-1.8.0+update181-1.x86_64.rpm as an example. The installation steps are very simple. You need to register an account to download from the Oracle official website. In order to facilitate everyone, you can directly link to the online disk: Extraction code: jbfd, please leave a message if it fails. https://pan.baidu.com/s/1D1c4LDoVU6kePzFCN4QCjQ

Install rpm package

Execute installation command

# 安装并打印进度
rpm -ivh oracle-j2sdk1.8-1.8.0+update181-1.x86_64.rpm

Installation process

Configure global environment variables

export JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH

Effective immediately

. /etc/profile

Verify installation

View version

java -version

result

installation path

Check the default installation path

[root@node1 ~]# which java
/usr/java/jdk1.8.0_181-cloudera/bin/java

Guess you like

Origin blog.csdn.net/BlogPan/article/details/132384949