Build a basic environment for Java development under Centos7

One, Centos7 install JDK

First check whether your own machine has its own openjdk, the command is as follows:

rpm -qa | grep jdk

If it exists, uninstall in turn according to the following commands:

yum -y remove fileName(fileName is each file found in the previous step)

After the uninstallation is complete, running the java command is not recognized by the system:

[ root@localhost ~]# java -version
bash: java: command not found...

Then, first download the tar.gz package of the required JDK version (this article takes jdk1.8 as an example)

Download link: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

After the download is complete, upload it to the centos7 server.

Note: Do not use the wget command to download directly, otherwise there will be an error in the next step of decompression, because you need to agree to the Oracle installation agreement before downloading the jdk on the Oracle official website, otherwise you cannot download it, but using wget, the default is not to agree. Although it can be downloaded, there will be problems with the downloaded file, so decompression on Linux has been failing.

Then unzip the downloaded tar.gz package to the installation location

mkdir -p /usr/local/java
tar -zxvf jdk-8u161-linux-x64.tar.gz -C /usr/local/java/

Then use the following command to edit the /etc/profile file (you must have vim installed on the system):

vim /etc/profile

Add the following at the end of the file:

export JAVA_HOME=/usr/local/java/jdk1.8.0_151
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

Finally, use the following command to make the configuration effective

source /etc/profile

After completion, to verify whether the installation is successful:

[ root@localhost local]# java -version
java version "1.8.0_151"Java(TM) SE Runtime Environment(build 1.8.0_151-b12)
Java HotSpot(TM)64-Bit Server VM(build 25.151-b12, mixed mode)

The output of the above version information means the installation is successful.

Two, Centos7 install Maven

First download the maven tar.gz package on the official website, the command is as follows (this article uses maven 3.5.0 as an example):

wget https://archive.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz

Then unzip the downloaded tar package to the installation location

mkdir -p /usr/local/maven
tar -zxvf apache-maven-3.5.0-bin.tar.gz -C /usr/local/maven/

Then we modify the /etc/profile file to configure environment variables (you need to have vim installed on the system):

vim /etc/profile

Change the environment variables of the JDK configuration into the following form:

export JAVA_HOME=/usr/local/java/jdk1.8.0_151
export JRE_HOME=${JAVA_HOME}/jre
export MAVEN_HOME=/usr/local/maven/apache-maven-3.5.0 #Add this line
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:${MAVEN_HOME}/bin:$PATH #Modify this line

Then run the following command to make the configured environment variables take effect:

source /etc/profile

After completion, to verify whether maven is installed successfully:

[ root@localhost a]# mvn -v
Apache Maven 3.5.0(ff8f5e7444045639af65f6095c62210b5713f426;2017-04-04T03:39:06+08:00)
Maven home:/usr/local/maven/apache-maven-3.5.0
Java version:1.8.0_151, vendor: Oracle Corporation
Java home:/usr/local/java/jdk1.8.0_151/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name:"linux", version:"3.10.0-514.16.1.el7.x86_64", arch:"amd64", family:"unix"

At this point, we have perfectly completed the installation and configuration of maven.

Note: If you find that maven download dependencies are very slow, the solution portal: http://www.cnblogs.com/hafiz/p/7566983.html

Three, Centos7 install Git

Installing git is very simple, just run the following command:

yum -y install git

After the installation is complete, run the following command to verify whether the installation is successful:

[ root@localhost a]# git --version
git version 1.8.3.1

Output the installed git version information to prove that the git installation is successful.

Four, summary

​ Through this article, we know how to install the basic environment of java under centos7, including JDK, Maven, Git. And clever you will find: the installation of JDK and Maven are surprisingly similar, and the analogy can be a good analogy. Like yourself~

Recommended Posts

Build a basic environment for Java development under Centos7
[PHP] Build a PHP operating environment under CentOS
Build a python development environment under Ubuntu
CentOS 7 configure Java language development environment
Build a PXC cluster under CentOS8
Build a LAMP development environment on Ubuntu 16.04
(1) Centos7 installation to build a cluster environment
Build a ScaleIO distributed storage cluster under CentOS7
Python3 development environment to build a detailed tutorial
Build Discuz Forum in LNMP Environment under CentOS7
Build LEMP (Linux+Nginx+MySQL+PHP) environment under CentOS 8.1 (detailed tutorial)
Build Dedecms website in LNMP environment under CentOS7
How to build a LAMP environment on centos7.2
Centos7.6 build LNMP environment
CentOS 7 build LNMP environment
Use Rancher to build a K8s cluster under CentOS7
[CentOS environment deployment] Java7/Java8 deployment under CentOS
Build OpenV** Server under CentOS7
CentOS 7 install JAVA environment (JDK 1.8)
Build OpenLDAP server under CentOS7
CentOS 7.2 deploy Node.js development environment
Install Java JDK8 under CentOS6
ubuntu build python development environment
Ubuntu 18.04.1 build Java environment and HelloWorld
CentOS 7 configure Ruby language development environment
Build an Ubuntu Linux development environment on a Vmware virtual machine
CentOS 7 configure php language development environment
Build an FTP server under centos7
Build Nginx environment on Linux (CentOS)
Centos7 build java web server tomcat
FFmpeg environment deployment record under centos7
CentOS 7 configure Python language development environment
PPTP environment deployment record under Centos
Tutorial diagram for installing zabbix2.4 under centos6.5
The software environment required for Centos7 installation
Centos7.5 configuration java environment installation tomcat explanation
Build the C++ compilation environment under ubuntu
Configure Java development environment in Ubuntu20.04 LTS
Graphical tutorial for installing JDK1.8 under CentOS7.4
Complete deployment record for LDAP under Centos7.2
Docker learning 2- quickly build a centos7-python3.6 environment
How to quickly build Nginx server under CentOS
Install MySQL 5.7 under CentOS 7 for middle class children!
Centos7 tutorial to build a master-slave DNS server