Skip to main content

Windows Installer for Apache Maven 2

I’ve been playing around with Windows Installer XML (WiX) recently – I used it to create the installer for Year Chart and I’ve since converted a couple of internal projects (I may publish them later) which I had originally created InstallShield installers for (with the version that came with older versions of Microsoft Visual Studio).

So, when I was involved in a discussion about installing Apache Maven 2 earlier this week I thought it sounded an interesting challenge.

I’m using Visual Studio 2010 with the Votive plugin for WiX projects and so, using this I created the base installer as an empty WiX project.  Then, I copied and tweaked some of the Year Chart installer (easier than starting from scratch…).

To get the Maven 2 binaries, I downloaded the Apache Maven 2.2.1 zipped binaries and expanded them into the project. I used the heat.exe program from the WiX installation to generate a Fragment file which will include all the Maven binary files into the installer.

Finally, I worked out how to setup the environment variables to support running Maven 2 on the command line: M2_HOME, M2, and adding M2 to Path. I’ve created them as User environment variables rather than System variables to make it easier to change them without Admin access.

Over the rest of the week, I added some Start Menu entries to uninstall the application and link to the Apache Maven web site. I also added the Apache License Version 2.0 – I had to use an RTF version because I couldn’t persuade WiX to use the text version included in the Maven distribution.


Note: I’ve now added a Download Page with installers for version 2 & 3 and added the sources to GitHub.

You can download the installer here:

The installer, as with the Apache Maven code, is provided under the Apache License Version 2.0.

This version of the installer includes the following features:

  • Installs Apache Maven 2.2.1 binaries (Jars)
  • Presents the Apache License Version 2.0
  • Configurable install location – defaults to:
    • C:Program FilesApache Software Foundationapache-maven-2.2.1
  • Configures User Environment Variables:
    • M2_HOME – the install location
    • M2 – the bin directory (includes mvn.bat)
    • Path – appends %M2% to the User path so you can use it easily on the command line.
  • Adds a Start Menu folder containing:
    • Apache Maven Website URL
    • Uninstall link

NOTE: Maven is a Java tool, so you must have a Java installed in order to proceed. More precisely, you need a Java Development Kit (JDK) version 1.5 or greater , the Java Runtime Environment (JRE) is not sufficient.

Once installed you will be able to run Maven from the command line – you can test this by opening a command window and typing:

mvn -version

What Next?

It’s time to give it a try – if you are new to Maven you might like to Test Drive Apache Maven on Your Existing Projects.

For me, there are a few extra installer features I’d like to try out – like checking the Java version.  And I will be adding more articles about Maven in the future.

Let me know if it’s any use to you – or if it you have any problems with it.

8 comments on “Windows Installer for Apache Maven 2”

  1. Uthere says:

    Thx Simon 🙂

  2. Anil says:

    Good one Simon …

  3. A.K.Dutta says:

    Getting Error on this command ….
    Would be please me to rectify the mistake

    C:workspace-newmaven-test>mvn archetype:generate -DgroupId=com.mkyong.core -DartifactId=mkyong-core -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
    [INFO] Scanning for projects…
    [INFO] Searching repository for plugin with prefix: ‘archetype’.
    [INFO] org.apache.maven.plugins: checking for updates from central
    [WARNING] repository metadata for: ‘org.apache.maven.plugins’ could not be retrieved from repository: central due to an error: Error transferring file: Connection reset
    [INFO] Repository ‘central’ will be blacklisted
    [INFO] ————————————————————————
    [INFO] ————————————————————————
    [INFO] The plugin ‘org.apache.maven.plugins:maven-archetype-plugin’ does not exist or no valid version could be found
    [INFO] ————————————————————————
    [INFO] For more information, run Maven with the -e switch
    [INFO] ————————————————————————
    [INFO] Total time: 42 seconds
    [INFO] Finished at: Fri Mar 16 17:53:17 IST 2012
    [INFO] Final Memory: 1M/2M
    [INFO] ————————————————————————
    ‘cmd’ is not recognized as an internal or external command,
    operable program or batch file.

  4. simon says:

    That doesn’t look like a problem with the installer – Maven was unable to retrieve the archetype plugin from “central” repository. It needs to have access to the internet to do this. Is your computer connected to the internet – and if there is an internet Proxy you will need to set that up. Some organisations also setup an internal Nexus or similar repository servers.

    Have a look at or

    Also, if you’re using it on a corporate network have a look at

  5. A.K.Dutta says:

    Thanks for your help .Installed succesfully.
    Would like to know how to execute .

    While executing gives error as :::
    Exception in thread “main” java.lang.NoClassDefFoundError: App (wrong name: com/
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(

    1. simon says:

      Without seeing the contents of it’s hard to say. Check that it is in the right directory (./src/main/java/com/mkyong/core) with a package com.mykong.core and a class inside called App.

  6. Quang Pham says:

    Your setup missed the “” after %M2_HOME% in the M2 env. variable. running the command mvn or anything in the bin directory will not work

    1. simon says:

      Hello, Quang Pham. I have checked installations with this installer on Windows 7 and XP and also verified the details in the WiX file. The trailing slash is definitely there and the “mvn” command works properly on all environments I have tried.

      Is it possible that you have an existing entry in your User or System environment variables that is affecting this? Do you have a particular system version that is affecting it?

Leave a Reply

Your email address will not be published. Required fields are marked *