Introduction to installing and configuring JDK under CentOS system

Introduction to installing and configuring JDK under CentOS system

Preface

When it comes to JDK, we have to mention an old interview question:
JDK (Java Development Kit)
JRE (Java Runtime Environment)
JVM (Java Virtual Machine)

insert image description here

I bought an Alibaba Cloud server on Singles’ Day, and it has been gathering dust ever since. Today I had nothing to do, so I took it out to play with it!
I have to say, Alibaba’s business is really fast. As soon as I made the purchase, the Alibaba staff called me to promote some services. I just said “I’m a student” and the topic was immediately ended!

insert image description here

After connecting remotely, I found that the host name is long and ugly, so I changed it first!

View the current host name

hostname

Modify the host name

hostnamectl set-hostname hayden 

insert image description here

Restart the service

insert image description here

Modification completed

insert image description here

Check and uninstall OpenJDK

Check Java related information to see if the system comes with OpenJDK and related installation packages. If so, uninstall them first.

java -version

rpm -qa | grep java

// rpm (RedHat Package Manger): RedHat software management tool, a tool used for packaging and installation // -qa (query, all)
// grep (global search rgular expression (RE) and print out the line): is a powerful text search tool 

insert image description here

If you find that OpenJDK and installation packages are installed, first uninstall them in sequence

rpm -e --nodeps tzdata-java-2012c-1.el6.noarch

rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64

// -e: Delete the specified package // --nodeps: Do not verify the interdependence of package files

Install JDK using the downloaded compressed package

Download the corresponding JDK version compressed package from Oracle official website to your local computer
Oracle - Java Downloads

insert image description here

Create a new java directory in the usr directory and use sftp to put the downloaded JDK compressed package into this directory

mkdir /usr/java
ll /usr 

insert image description here

insert image description here

Enter the java directory and unzip the JDK compressed package. After the unzipping is complete, you can choose whether to delete the compressed package based on your mood!

cd /usr/java
ll
tar -zxvf jdk-8u311-linux-x64.tar.gz
ls

insert image description here

insert image description here

JDK environment configuration

Edit the profile file, add the following configuration at the end of the file, save and exit

vim /etc/profile

export JAVA_HOME=/usr/java/jdk1.8.0_311 
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar 
export PATH=$PATH:$JAVA_HOME/bin

insert image description here

vim / vi editor shortcuts

:set nu // Display line number G // Jump to the last line of text G$ // Jump to the last character of the last line gg // Jump to the first character of the first line 0 // Jump to the first character of the current line

Reload the /etc/profile file through the source command to make the configuration effective

source /etc/profile 

insert image description here

Test whether the configuration is successful

Enter the following command, and the following information is displayed, indicating that the configuration is successful

java -version 

insert image description here

Of course, there is more than one way to install JDK. You can also install JDK through yum and rpm commands, but the configuration method is the same, exposing the JDK related paths

Install JDK via yum command

Search for JDK installation packages

yum search java | grep jdk

insert image description here

Download JDK, the default path is: /usr/lib/jvm/

yum install java-1.8.0-openjdk.x86_64

Install JDK through rpm command

Download the rpm installation package

wget http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.rpm?AuthParam=1534132498_e541d098d71f6243516fa69cd17eba60

Install JDK

rpm -ivh jdk-8u181-linux-x64.rpm?AuthParam=1534132498_e541d098d71f6243516fa69cd17eba60

This is the end of this article about installing and configuring JDK under CentOS system. For more relevant CentOS configuration JDK content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Centos 7 installation of OpenJDK 11 two ways and problem summary
  • Centos installation jdk case explanation
  • Graphical tutorial on installing JDK1.8 under CentOS7.4
  • Install JDK8 in rpm mode on CentOS7

<<:  3 functions of toString method in js

>>:  The most comprehensive collection of front-end interview questions

Recommend

Detailed explanation of browser negotiation cache process based on nginx

This article mainly introduces the detailed proce...

Detailed steps to install CentOS7 system on VMWare virtual machine

Pre-installation work: Make sure vmware workstati...

Sample code for converting video using ffmpeg command line

Before starting the main text of this article, yo...

JavaScript array deduplication solution

Table of contents Method 1: set: It is not a data...

Nginx rewrite regular matching rewriting method example

Nginx's rewrite function supports regular mat...

MySQL executes commands for external sql script files

Table of contents 1. Create a sql script file con...

Three Vue slots to solve parent-child component communication

Table of contents Preface Environment Preparation...

Vue implements zoom in, zoom out and drag function

This article example shares the specific code of ...

Solutions to MySQL batch insert and unique index problems

MySQL batch insert problem When developing a proj...

How to uninstall MySQL 5.7 on CentOS7

Check what is installed in mysql rpm -qa | grep -...

This article takes you to explore NULL in MySQL

Table of contents Preface NULL in MySQL 2 NULL oc...

How to view the docker run startup parameter command (recommended)

Use runlike to view the docker run startup parame...

Specific method of viewing user authorization information in mysql

Specific method: 1. Open Command Prompt 2. Enter ...

Detailed Introduction to Nginx Installation and Configuration Rules

Table of contents 1. Installation and operation o...

How to deeply understand React's ref attribute

Table of contents Overview 1. Creation of Refs ob...