Chapter 1. Prerequisites to Using This Guide
1.1. Install Maven
Procedure 1.1. Install Maven
Verify Java Developer Kit 1.6 or above is installed. This is also a requirement for the Enterprise Platform.
Ensure you have Java installed on your system, and have set theJAVA_HOME
environment variable in your~/.bash_profile
for Linux, or in the System Properties for Windows. For more information regarding setting environment variables, refer to the Step 4 step in this procedure.Download Maven
Note
This step and future steps assume that you have saved Maven to the suggested location for your operating system. Maven, as any other Java application, is able to be installed in any reasonable location on your system.Click the compiled zip archive link, for exampleapache-maven-2.2.1-bin.zip
Select a download mirror from the list.For Linux UsersSave the zip archive to your
home
directory.For Windows UsersSave the zip archive to your
C:\Documents and Settings\user_name
directory.Install Maven
For Linux UsersExtract the zip file to your
home
directory. If you selected the zip archive in Step 2, and do not rename the directory, the extracted directory is namedapache-maven-version
.For Windows UsersExtract the zip archive to C:\Program Files\Apache Software Foundation. If you selected the zip archive in Step 2, and do not rename the directory, the extracted directory is named
apache-maven-version
.Configure Environment Variables
For Linux UsersAdd the following lines to your
~/.bash_profile
. Ensure you change the [username] to your actual username, and that the Maven directory is the actual directory name. The version number may be different than the one listed below.export M2_HOME=/home/[username]/apache-maven-2.2.1 export M2=$M2_HOME/bin export PATH=$M2:$PATH
By includingM2
at the beginning of your path, the Maven version you just installed will be the default version used. You may also want to set the path of yourJAVA_HOME
environment variable to the location of the JDK on your system.For Windows UsersAdd the
M2_HOME
,M2
, andJAVA_HOME
environment variables.- Press Start+Pause|Break. The System Properties dialog box is displayed.
- Click the Advanced tab, then click the Environment Variables button.
- Under System Variables, select Path.
- Click Edit, and append the two Maven paths using a semi-colon to separate each entry. Quotation marks are not required around paths.
- Add the variable
M2_HOME
and set the path toC:\Program Files\Apache Software Foundation\apache-maven-2.2.1
. - Add the variable
M2
and set the value to%M2_HOME%\bin
.
- In the same dialog, create the
JAVA_HOME
environment variable:- Add the variable
%JAVA_HOME%
and set the value to the location of your JDK. For exampleC:\Program Files\Java\jdk1.6.0_02
.
- In the same dialog, update or create the Path environment variable:
- Add the variable
%M2%
to allow Maven to be executed from the command-line. - Add the variable
%JAVA_HOME%\bin
to set the path to the correct Java installation.
- Click OK until the System Properties dialog box closes.
Implement changes to .bash_profile
For Linux Users OnlyTo update the changes made to the .bash_profile in the current terminal session, source your .bash_profile.
[localhost]$ source ~/.bash_profile
Update gnome-terminal profile
For Linux Users OnlyUpdate the terminal profile to ensure that subsequent iterations of gnome-terminal (or Konsole terminal) read the new environment variables.
- Click Edit → Profiles
- Select Default, and click the Edit button.
- In the Editing Profile dialog, click the Title and Command tab.
- Select the Run command as login shell check box.
- Close all open Terminal dialog boxes.
Verify the environment variable changes and Maven install
For Linux UsersTo verify that the changes have been implemented correctly, open a terminal and execute the following commands:
- Execute
echo $M2_HOME
, which should return the following result.[localhost]$ echo $M2_HOME /home/username/apache-maven-2.2.1
- Execute
echo $M2
, which should return the following result.[localhost]$ echo $M2 /home/username/apache-maven-2.2.1/bin
- Execute
echo $PATH
, and verify the Maven/bin
directory is included.[localhost]$ echo $PATH /home/username/apache-maven-2.2.1/bin
- Execute
which mvn
, which should display the path to the Maven executable.[localhost]$ which mvn ~/apache-maven-2.2.1/bin/mvn
- Execute
mvn -version
, which should display the Maven version, related Java version, and operating system information.[localhost]$ $ mvn -version Apache Maven 2.2.1 (r801777; 2009-08-07 05:16:01+1000) Java version: 1.6.0_0 Java home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre Default locale: en_US, platform encoding: UTF-8 OS name: "Linux" version: "2.6.30.9-96.fc11.i586" arch: "i386" Family: "unix"
For Windows UsersTo verify that the changes have been implemented correctly, open a terminal and execute the following command:
- In a command prompt, execute
mvn -version
C:\> mvn -version Apache Maven 2.2.1 (r801777; 2009-08-06 12:16:01-0700) Java version: 1.6.0_17 Java home: C:\Sun\SDK\jdk\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"