What you need to Install Maven in Windows
1) Make sure JDK is already installed. You need JDK 1.7 or above to run Maven 3.3. If you don't know how to install Java, see this guide for step by step tutorial.2) Make sure that JAVA_HOME environment variable is defined and should point to the installation directory of Java. Maven uses this environment variable to find the Java installation directory. See here to learn more about JAVA_HOME environment variable.
Once you ensure that above is in place, you need to follow below steps to install Maven on your Windows machine:
1) Setup following environment variables
export M2_HOME=/Users/xxx/sdk/apache-maven-3.2.3 export M2=$M2_HOME/bin export MAVEN_OPTS="-Xmx1048m -Xms256m -XX:MaxPermSize=312M" export PATH=$M2:$PATH
I am using Cygwin that's why I am using the export command if you are using DOS command prompt then you should use the "set" command version shown below.
set M2_HOME=C:\\software\apache-maven-3.2.3 set M2=%M2_HOME%\bin set MAVEN_OPTS="-Xmx1048m -Xms256m -XX:MaxPermSize=312M" set PATH=%M2%;%PATH%
Though simply adding the bin directory of Maven installation folder to PATH is enough to run the "mvn" command, it's better to define well-known maven environment variables like M2_HOME and MAVEN_OPTS.
The M2_HOME is equivalent to JAVA_HOME and should point to the installation directory of Maven. On the other hand, MAVEN_OPTS is used by Maven script to fetch additional JVM arguments provided by the user. You can use this environment variable to increase the heap size of Maven by supplying JVM memory arguments e.g. -Xms and -Xmx.
You can also read Maven Essentials to learn more about how Maven uses these environment variables.

One you have to add bin directory of Maven folder, either directly or indirectly via an M2 environment variable, you should be able to run the mvn command from Cygwin or DOS command prompt. If Maven is setup correctly you will see similar output as shown below:
You can see that it prints the Apache Maven version, along with Maven home, Java version, Java home and OS name.$ mvn -version Apache Maven 3.2.3 Maven home: C:\apache-maven-3.2.3 Java version: 1.6.0_37, vendor: Sun Microsystems Inc. Java home: C:\Java\jdk1.6.0_37\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
At this point of time installation of Apache Maven is completed successfully and you are now ready to create and build Maven based Java project using different arch types. You can also use this locally installed Maven in eclipse instead of the default one installed by M2Eclipse plugin.
No comments:
Post a Comment