Maven Installation

Before this point, I always use IDE to run Maven projects. However, today when I typed mvn clean, and the error message popped up:

1
2
'mvn' is not recognized as an internal or external command,
operable program or batch file.

I realized that I did not install Maven on my local machine… Shame on me…

Again, I used Windows.

Almost forgot this post…

In this post, assuming that JDK has been configured properly.

Download Maven

  1. As for now, the most current version is 3.6.1, so go to the official website download apache-maven-3.6.1-bin.zip file.
  2. Unzip the file, and place somewhere that is easily remembered or organized.

Surprisingly, installation of Maven is not required.


Add Variables

  1. Search environment in the windows search bar, and open Edit the system environment variables.
  2. Click on the Environment Variables.
  3. Select System variables, add click on New.... Set MAVEN_HOME for Variable name:, and past the path from step 1.2 to Variable value:.
  4. Select Path under System variable, then, click New. Finally, add %MAVEN_HOME%\bin to Path.

Check Maven

  1. Open new prompt, and check following:

    1
    2
    $ echo %MAVEN_HOME%
    C:\apache-maven-3.6.1

    If no message has prompted, or just prints out %MAVEN_HOME%, which means MAVEN_HOME has not ye been configured, go back to 2.2.

  2. Open new prompt, and check following:

    1
    2
    3
    4
    5
    6
    $ mvn -v
    Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
    Maven home: C:\apache-maven-3.6.1\bin\..
    Java version: 11, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11
    Default locale: en_US, platform encoding: GBK
    OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Something Else

What is an environment variable in windows?

Simply, it is a variable for the environment. To be more specific, it’s a easily remembered variable which points to the actual location of the environment.

In this case, the name for the environment variable is MAVEN_HOME, and the specific path for the environment is C:\apache-maven-3.6.1.

The PATH, which is also an environment variable but used to store all other environment variables. When other programs, for instance, in the process 3.2, typing mvn -v in prompt, or earlier as I said I entered mvn clean in Intellij, they start searching the specific variables that stored in the PATH, if not found, the error message will appear on the scree.

Hence, point the executable in the PASH is important and the final steps in setting up environments for windows, and potentially any Unix-based systems, since wikipedia says:

PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.

wikipedia: PATH (variable)>)

-------The end of this article  Thank you for your reading-------
0%