Java-JDK installation and configuration under CentOS

Java-JDK installation under CentOS###

There are usually several ways to install jdk in CentOS 7 system:

This article demonstrates how to install via yum

  1. Execute the following command to search for the jdk installation package

yum search java|grep jdk

  1. Select JDK1.8 version to install
    yum install java-1.8.0-openjdk

After the installation is complete, enter java -vsersion to check whether the installation is successful

  1. By default, there is only the running environment after the installation, which means that there is only the jre folder in the java installation directory. When we execute the javac command, it will prompt "Command not found", so you need to install jdk next
    yum install java-1.8.0-openjdk-devel.x86_64

Use javac to test, the following text appears indicating that the installation is successful

Configure environment variables such as JAVA_HOME###

Installing jdk through yum install will not automatically configure the JAVA_HOME environment variable. If some services rely on this environment variable, they will fail to start. The following demonstrates how to manually configure the JAVA_HOME environment variable.

  1. Find the JDK installation path
which java
Output:/usr/bin/java
  
ls -lr /usr/bin/java
Output:/usr/bin/java ->/etc/alternatives/java
  
ls -lrt /etc/alternatives/java
Output:/etc/alternatives/java ->/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/bin/java

Find location:

/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64

  1. Configure JAVA_HOME, execute the command
    vim /etc/profile

Add the following configuration inside
(The JAVA_HOME parameter is set according to the directory path found above)

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64
# The above is the output of ls above, pay attention to remove the end/jre/bin/Java, if you do not follow the above steps exactly, you may need to change this
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
  1. Finally, execute the following command to make the configuration effective:
    source /etc/profile

test
Execute: echo $JAVA_HOME

over ~~~

Recommended Posts

Java-JDK installation and configuration under CentOS
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
Installation and configuration of redis under centos7
Centos mysql installation and configuration
Centos7 installation and configuration prometheus
CentOS 7 installation and configuration PPTP
CentOS installation and configuration cmake
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
CentOS 7 installation and configuration graphic tutorials under VMware10
Installation and configuration of rsync server under CentOS 6.5
Centos7 installation and configuration of Jenkins
Centos7 hadoop cluster installation and configuration
CentOS 7 Tomcat service installation and configuration
CentOS NTP server installation and configuration
Erlang 20.2 installation and deployment under CentOS 7
Centos7 mysql database installation and configuration
Detailed explanation of Spark installation and configuration tutorial under centOS7
CentOS 7 system installation and configuration graphic tutorial
Installation and use of Mysql under CentOS
Zabbix installation and deployment and localization under CentOS
Centos7 hive stand-alone mode installation and configuration
Jenkins installation and deployment tutorial under CentOS 7
KVM installation and preliminary use under CentOS 7.2
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
OpenMPI-Ubuntu installation and configuration
Mysql8.0.15 installation configuration (centos7)
Redis3 installation under Centos7
CentOS 6.5 system installation and configuration graphic tutorial (detailed graphic)
Kaldi installation and configuration graphic tutorials under Ubuntu
Installation and configuration of CentOS 7 in VMware Workstation
MySQL 8.0 installation and deployment under CentOS, super detailed!
Installing CentOS 6 and SSH configuration under Windows 8 Hyper-V
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Redis cluster installation under CentOS
centos7 kvm installation and use
CentOS7 postgresql installation and use
Ubuntu PostgreSQL installation and configuration
Centos7 elk7.1.1 installation and use
Installation and cracking of confluence6.3 operation records under Centos
Ubuntu16.04 mirror complete installation and configuration tutorial under VMware
Installation and cracking of Jira7 operation records under Centos
Environment configuration of JDK, mysql and tomcat under Centos7
Install and configure keepalived under CentOS 5.9
Compile and install LAMP under Centos 5.2
CentOS 8 install Git and basic configuration
Centos6.5 installation and deployment of KVM
CentOS7 installation and maintenance of Gitlab
Deploy and optimize Tomcat under Centos
Redis installation under ubuntu and windows
Install Python3 and ansible under CentOS8
Install and use docker under CentOS 6.8
Centos 7 RAID 5 detailed explanation and configuration
Ubuntu 19.1 installation and configuration Chinese environment
Configuration and beautification after Ubuntu installation (1)
2019-07-09 CentOS7 installation
centos7_1708 installation
Nginx installation and configuration load (ubuntu12.04)
Install Python3 and Py under CentOS7
CentOs7 installation and deployment Zabbix3.4 original
Ubuntu configuration source and installation software