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.
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
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.
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