Steps of installing JDK in linux

1. Check the jdk version in the system (some systems have their own jdk) [root@localhost software]# java -version If there is no jdk, there will be n...
Next comes the play, download and install the new jdk

1. Check the jdk version in the system (some systems have their own jdk)

[root@localhost software]# java -version

If there is no jdk, there will be no reaction. If there is, it will show:

openjdk version "1.8.0_102" OpenJDK Runtime Environment (build 1.8.0_102-b14) OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)

2. Check the jdk installation package

[root@localhost software]# rpm -qa | grep java

Show:

java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64 python-javapackages-3.4.1-11.el7.noarch tzdata-java-2016g-2.el7.noarch javapackages-tools-3.4.1-11.el7.noarch java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64 java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64 java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64

3. Uninstall openjdk

[root@localhost software]# rpm -e --nodeps tzdata-java-2016g-2.el7.noarch [root@localhost software]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64 [root@localhost software]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64 [root@localhost software]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64 [root@localhost software]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64

Or use the yum command

[root@localhost jvm]# yum remove *openjdk*

After that, input rpm -qa | grep java again to check the unloading situation

[root@localhost software]# rpm -qa | grep java python-javapackages-3.4.1-11.el7.noarch javapackages-tools-3.4.1-11.el7.noarch

Next comes the play, download and install the new jdk

Method 1: use yum fool installation

This method is simple and rough, and it can be operated directly.

1. First, execute the following command to view the installable version of jdk:

yun -y list java*

After successful execution, you can see the following interface:

2. Select the version of jdk you need to install. Install jdk1.8 here

yum install -y java-1.8.0-openjdk-devel.x86_64

3. After installation, check the installed jdk version, and enter the command:

java -version

You can see the version information of your own jdk installation here. They can be found under usr/lib/jvm.

Method 2: manual installation (personal recommendation)

Personal suggestion is better to install it manually. You can install it in the directory you want to install, which will deepen your experience. ok, then start to install manually (connect your own virtual machine installation with xshell tool)!

1. Go to the Oracle official website to download the version of JDK that needs to be installed. I use jdk-8u181-linux-x64.tar.gz here

2. Put the compressed package in the directory / usr/local/jdk. The jdk directory needs to be created manually by yourself, or java, and the name can be chosen freely by yourself (you can count on it). Then decompress the compressed package and input the following instructions:

tar zxvf jdk-8u181-linux-x64.tar.gz

After successful decompression, it shows:

3. Next, configure the environment variable by entering the following command:

vim /etc/profile

Enter after input, and add the following environment variable information at the end of the file:

export JAVA_HOME=/usr/local/jdk/jdk1.8.0_181 export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/ export PATH=$PATH:$JAVA_HOME/bin

Note: in the first line, java_home = / usr / local / JDK / jdk1.8.0 µ to the right of the equal sign here is the actual decompression directory of your own JDK. If it is not, you need to change it to your own actual directory, and others remain unchanged.

The actual situation is as follows:

4. After editing, save and exit, and then input the following instructions to refresh the environment configuration to make it effective:

source /etc/profile

5. Check whether the jdk is installed successfully. Enter the Java version command.

6. Installation is completed.

A sudden encounter Published 9 original articles, won praise 19, visited 10000+ Private letter follow

13 January 2020, 04:02 | Views: 8789

Add new comment

For adding a comment, please log in
or create account

0 comments