1. Check if the JDK is installed, and set the environment variable (java_home):
Echo $JAVA _home
Java-version
Operation Result:
Displays the installation path of the JDK, and the Java version, such as:
#jdk路径
/usr/lib/jvm/jdk1.8.0_112
#java版本
Java Version "1.8.0_112"
Java (TM) SE Runtime Environment (build 1.8.0_112)
Java HotSpot (TM) 64-bit Server VM (build 25.112-b15, Mixed mode)
Note: If it is not installed, please install the JDK first (this is not explained in detail here)
2. Download and install
Download the MAVEN installation file to http://maven.apache.org/download.cgi , such as apache-maven-3.0-bin.tar.gz, then unzip to the local directory:
wget https://archive.apache.org/dist/maven/binaries/apache-maven-3.0-bin.tar.gz
TAR-ZXVF apache-maven-3.0-bin.tar.gz
This creates a Maven installation directory apache-mmaven-3.0, which can be used after configuring environment variables directly, but for future upgrades it is recommended to create a symbolic link:
Ln-s apache-maven-3.0 Apache-maven
Next, create the MAVEN environment variable maven_home, and set the path
Export Maven_home=~/apache-maven #上面的安装路径
Export path= $PATH: $MAVEN _home/bin
In general, these two lines of command need to be added to the system's login shell script to Ubuntu16.04, edit the ~/.BASHRC file, add the two lines of command. Such
Here, the installation is complete. You can run the command to check if the MAVEN installation was successful:
Echo $MAVEN _home
Mvn-v
After running, it should show:
MAVEN's installation path and MAVEN version information, such as:
/home/jv/workplace/apache-maven
Apache Maven 3.0 (r1004208; 2010-10-04 19:50:56+0800)
Java version:1.8.0_112
Java Home/usr/lib/jvm/jdk1.8.0_112/jre
Default Locale:en_us, Platform Encoding:utf-8
OS name: "Linux" version: "4.4.0-22-generic" arch: "AMD64 Family:" Unix "
Maven (i) installation under Linux