Install and Configure Maven for Eclipse

Apache Maven is a project dependency manager often used in Eclipse projects. It automatically downloads the packages your project depends on, and downloads the packages those packages depend on, etc.

Each project’s pom.xml file tells Maven what packages to download.  You can search for Maven-supported packages and their current versions at The Maven Central Repository.

Install Maven

  1. Browse to Apache Maven Downloads
  2. In the Files section, in the Binary Zip Archive row, click on apache-maven-3.3.3-bin.zip
  3. Unzip the resulting file somewhere under your Documents folder.  Something like C:\Users\YourLogin\Documents\apache-maven-3.3.3  I do this instead of putting it in C: or Program Files because I’ve had permissions issues when I put unzipped archives there.
  4. Add the bin folder of the unzipped tree to your PATH Environment Variable.  Be sure to include the semicolon to separate this from the rest of the PATH contents.  Your bin folder will be something like C:\Users\YourLogin\Documents\apache-maven-3.3.3\bin
    1. Note: to edit environment variables in WIndows 7 and 8, open Windows Explorer (file manager), right-click on Computer (Windows 7) or This PC (Windows 8) and select Properties.  In the resultant window, click on Advanced System Settings. In the resultant window (after confirming), click on Environment Variables…. From there you can Add, Edit, and Delete Environment Variables.
  5. Open a Command Prompt window and type mvn -v
  6. Maven should print its configuration information.

Update Eclipse’s Maven Plugin

  1. Start Eclipse,
  2. Click on Help / Install New Software…
  3. In the Work with field type http://download.eclipse.org/technology/m2e/releases/
  4. Click Add
  5. In the Name field, type M2E
  6. Click OK
  7. Once Eclipse downloads the file, the Name field should show Maven Integration for Eclipse
  8. Click the checkbox (select) Maven Integration for Eclipse
  9. Click Next
  10. Click Next
  11. Read the terms of use, and if you agree click I accept the terms…
  12. Click Finish
  13. When prompted, restart Eclipse

If you have a proxy, configure the Maven Proxy settings

Each time you create a new Workspace in Eclipse, you’ll need to tell it about the file you create here.

  1. Create a new text file in Documents, named mavensettings.xml
  2. Copy and paste the following text into that file, adjusting the fields for your environment:

    <settings>
    <proxies>
    <proxy>
    <active>true</active>
    <protocol>http</protocol>
    <host>proxy.mycorp.com</host>
    <port>911</port>
    <nonProxyHosts>*.mycorp.com</nonProxyHosts>
    </proxy>
    </proxies>
    </settings>
  3. In Eclipse,
  4. Click on Window / Preferences / Maven / User Settings
  5. For User Settings, click the Browse button
  6. Navigate to your newly created mavensettings.xml file
  7. Click Open
  8. Click Update Settings
  9. Click OK
  10. Restart Eclipse

Add the Maven Central Catalog of Archetypes

Each time you create a new Workspace in Eclipse, you’ll need to repeat these steps for that Workspace.

Maven Archetypes are patterns for creating projects.  The default list of Archtetypes is very limited, so we add the Maven Central Catalog.

  1. In Eclipse,
  2. Click on Window / Preferences / Maven / Archetypes
  3. Click Add Remote Catalog…
  4. For Catalog file, type http://repo.maven.apache.org/maven2/archetype-catalog.xml
  5. For Description, type Maven Central
  6. Click Verify and wait a bit for Eclipse to load the catalog
  7. Eventually a message should appear near the dialog top, saying something like “Found 14138 archetype(s)
    1. If instead you see the error message “remote catalog is empty“, Eclipse/Maven failed to download the catalog.  I’ve seen this most often when the proxy settings are incorrect.  Check them. Try clicking the reindex button – that seemed to help me once.
  8. Click OK
  9. Click OK