Maven-Environment configuration
Maven is a Java-based tool, so the first thing to do is install the JDK.
System Requirements
Project |
Requirements |
Jdk |
Maven 3.3 requires JDK 1.7 or higher Maven 3.2 requires JDK 1.6 or higher Maven 3.0/3.1 requires JDK 1.5 or above |
Memory |
No minimum requirements |
Disk |
Maven's own installation requires approximately ten MB of space. In addition, additional disk space will be used for your local Maven repository. The size of your local warehouse depends on usage, but it is expected to be at least one MB |
Operating system |
No minimum requirements |
Step 1: Check the Java installation
Now open the console and execute the following java
command.
Operating System |
Task |
Command |
Windows |
Open Command Console |
c:\> java -version |
Linux |
Open Command Terminal |
$ java -version |
Mac |
Open Terminal |
machine:~ joseph$ java -version |
Let's verify the output on all platforms:
Operating System |
Output |
Windows |
Java Version "1.6.0_21" Java (TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot (TM) Client VMs (build 17.0-b17, mixed mode, sharing) |
Linux |
Java Version "1.6.0_21" Java (TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot (TM) Client VMs (build 17.0-b17, mixed mode, sharing) |
Mac |
Java Version "1.6.0_21" Java (TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot (TM) 64-bit Server VM (build 17.0-b17, mixed mode, sharing) |
If you do not have Java installed, install the Java Software Development Kit (SDK) from the following URL:http://www.oracle.com/technetwork/java/javase/downloads/index.html. We assume that the Java version you installed is 1.6.0_21.
Step 2: Set up the Java environment
Set the JAVA_HOME
environment variables and point to the Java installation directory on your machine. For example:
Operating System |
Output |
Windows |
Set the environment variable Java_home to C:\Program files\java\jdk1.6.0_21 |
Linux |
export JAVA_HOME=/usr/local/java-current |
Mac |
export JAVA_HOME=/Library/Java/Home |
Add the Java compiler address to the system path.
Operating System |
Output |
Windows |
The string "; C:\Program Files\java\jdk1.6.0_21\bin "added to the end of system variable" Path " |
Linux |
Export path= $PATH: $JAVA _home/bin/ |
Mac |
Not required |
Use the Java-version command mentioned above to Verify the Java installation.
Step 3: Download the Maven file
Download Maven 3.2.5 from the following URL:http://maven.apache.org/download.html
Step 4: Unzip the Maven file
Unzip the file to the location you want to install Maven 3.2.5 and you will get the apache-maven-3.2.5 subdirectory.
Operating System |
location (depending on your installation location) |
Windows |
C:\Program Files\Apache Software Foundation\apache-maven-3.2.5 |
Linux |
/usr/local/apache-maven |
Mac |
/usr/local/apache-maven |
Step 5: Set up the Maven environment variable
Add M2_home, M2, maven_opts to environment variables.
Operating System |
Output |
Windows |
Set environment variables using System properties. M2_home=c:\program Files\apache Software foundation\apache-maven-3.2.5 M2=%m2_home%\bin maven_opts=-xms256m-xmx512m |
Linux |
Open the command terminal to set environment variables. Export m2_home=/usr/local/apache-maven/apache-maven-3.2.5 Export m2= $M 2_home/bin Export maven_opts= "-xms256m-xmx512m" //Note plus double quotes |
Mac |
Open the command terminal to set environment variables. Export m2_home=/usr/local/apache-maven/apache-maven-3.2.5 Export m2= $M 2_home/bin Export maven_opts=-xms256m-xmx512m |
Step 6: Add the Maven Bin directory to the system path
Now add the M2 variable to the system "Path" variable
Operating System |
Output |
Windows |
Add a string ";%m2%" to the end of the system "Path" variable |
Linux |
Export path= $M 2: $PATH |
Mac |
Export path= $M 2: $PATH |
Step 7: Verify the Maven installation
Now open the console and execute the following mvn command.
Operating System |
Output |
Command |
Windows |
Open Command Console |
c:\> mvn --version |
Linux |
Open Command Terminal |
$ mvn --version |
Mac |
Open Terminal |
machine:~ joseph$ mvn --version |
Finally, verify that the output of the above command should look like this:
Operating System |
Output |
Windows |
Apache Maven 3.2.5 (r801777; 2009-08-07 00:46:01+0530) Java version:1.6.0_21 Java Home:c:\program Files\java\jdk1.6.0_21\jre |
Linux |
Apache Maven 3.2.5 (r801777; 2009-08-07 00:46:01+0530) Java version:1.6.0_21 Java Home:c:\program Files\java\jdk1.6.0_21\jre |
Mac |
Apache Maven 3.2.5 (r801777; 2009-08-07 00:46:01+0530) Java version:1.6.0_21 Java Home:c:\program Files\java\jdk1.6.0_21\jre |
Congratulations! You have completed all the settings and started using Apache Maven.
Source: http://wiki.jikexueyuan.com/project/maven/environment-setup.html
When you are finished, if you are prompted for path/APACHE-MAVEN-XX/BIN/MVN: Insufficient permissions
Use the chmod 777 path/APACHE-MAVEN-XX/BIN/MVN to resolve.
The Linux installation MVN prompt for insufficient permissions