Show Table of Contents
2.2. Install Maven
Maven is a build system for projects that use the Project Object Model (POM). It downloads package dependencies quickly and easily. If you have an infrastructure team providing your Red Hat JBoss Data Virtualization environment, you can skip this procedure. Otherwise, you will need to follow it to install Maven to build your projects.
Prerequisites
The following software must be installed:
- An archiving tool for extracting the contents of compressed files.
- Open JDK.
Procedure 2.1. Install Maven
Download Maven.
- Download the
apache-maven-[latest-version]ZIP file.
Install and configure Maven.
On Red Hat Enterprise Linux
- Extract the ZIP archive to the directory where you wish to install Maven.
- Open your .bash_profile file:
vi ~/.bash_profile
- Add the M2_HOME environment variable to the file:
export M2_HOME=/path/to/your/maven
- Add the M2 environment variable to the file:
export M2=$M2_HOME/bin
- Add the variable $JAVA_HOME/bin to set the path to the correct Java installation.
Note
Make sure JAVA_HOME is pointing to a valid location. - Add the M2 environment variable to the file:
export PATH=$M2:$PATH
- Save the file and exit your text editor.
- Reload your profile:
source ~/.bash_profile
- Run the following command to verify that Maven is installed successfully on your machine:
mvn --version
On Microsoft Windows
- Extract the ZIP archive to the directory where you wish to install Maven. The subdirectory
apache-maven-[latest-version]is created from the archive. - Press Start+Pause|Break. The System Properties dialog box is displayed.
- Click the Advanced tab and click Environment Variables.
- Under System Variables, select Path.
- Click Edit and add the two Maven paths using a semicolon to separate each entry.
- Add the M2_HOME variable and set the path to
C:\path\to\your\Maven. - Add the M2 variable and set the value to %M2_HOME%\bin.
- Update or create the Path environment variable:
- Add the %M2% variable 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 to close all the dialog boxes including the System Properties dialog box.
- Open Windows command prompt and run the following command to verify that Maven is installed successfully on your machine:
mvn --version

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.