Maven 3 installation and configuration

In this tutorial we are going to show how to set up a working maven 3 installation.
Follow this steps:
- Download maven 3
- Install maven 3
- Configure maven 3
- Check setup


1. Download maven 3


- Navigate to http://maven.apache.org/download.html
- Download binary ZIP archive

2. Install maven 3


- Unpack ZIP archive to a directory of your choosing that suits your needs

3. Configure maven 3


We are going to configure our maven installation to use a custom repository directory.
- Create a directory for your repository
- Navigate to conf/settings.xml file of your maven installation
- Locate localRepository tag and change its value to a directory that you just created
- Add M2_HOME variable pointing to your maven installation
- Add bin directory of your maven installation to a PATH variable

4. Check setup


We are going to check if we can setup a simple test project with maven.
- Run a command line window – cmd command
- Enter following command

mvn archetype:create –DgroupId=com.itcuties –DartifactId=test

After maven downloads all the needed resources for executing this command a new test project is created.

10 Responses to "Maven 3 installation and configuration"

  1. Iman Syaefulloh says:

    Help me please, i’m noob i got this message “mvn is not recognized as an internal or external command” after i type this mvn archetype:create –DgroupId=com.itcuties –DartifactId=test

    Thanks

    Reply
    • itcuties says:

      It seems that maven’s bin directory is not added to your system’s PATH variable.
      Take care,
      itcuties

      Reply
  2. Karl says:

    Help when i run the command i get this error message:

    ERROR: JAVA_HOME not found in your environment. please set the java_home variable in your environment to match the location of your Java installation

    Thanks

    Reply
    • itcuties says:

      Hey Karl, you need to set the JAVA_HOME environment variable to point to the Java SDK installation. Do this…

      Under Linux/Other Unix:

      export JAVA_HOME=[PATH_TO_SDK_INSTALLATION_FOLDER]
      

      Under Windows:

      Start -> [right click] Computer -> Properties -> Advanced system settings -> Environment variables (button) -> New (button – set it for your user)
      We hope this helps! Take IT easy … and share our page with your friends! ;)

      Reply
  3. Rohit More says:

    Hello Admin,
    Actually I am also facing same problem . JAVA_HOME not set.
    even I set up JAVA_HOME variable and java and javac is working fine.
    but with mvn its not working . Same message is getting.

    Is there any configuration file where i need to put JAVA_HOME Path in maven Folder ?

    Reply
    • itcuties says:

      There is no magic with this configuration :) You have to have a mistake in you JAVA_HOME – where does it point? java and javac commands are working fine because you have added your Java’s bin folder to your PATH variable. Remember, when setting JAVA_HOME variable it should point to your Java installation folder and not to the bin folder like PATH variable does. Double check your JAVA_HOME setting. There has to be a typo or something :)

      Reply
  4. UzarCif says:

    Hey Admin,

    I have this Error:

    [ERROR] The goal you specified requires a project to execute but there is no POM
    in this directory (E:\MavenWorkspace). Please verify you invoked Maven from the
    correct directory. -> [Help 1]

    should i import a project containin a pom.xml file into the repo directory ?

    Reply
  5. Check setup - is not creating the project says:

    I tried to create the test project by running the Check set command given in step 4.
    Its showing the below error. Can you please suggest what is the error….

    —————————————————————————————————————————————————————

    c:\Web_Workspace>mvn archetype:create -DgroupId=com.itcuties -DartifactId=test
    [INFO] Scanning for projects…
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 0.126s
    [INFO] Finished at: Thu Sep 25 16:33:24 BST 2014
    [INFO] Final Memory: 3M/15M
    [INFO] ————————————————————————
    [ERROR] The goal you specified requires a project to execute but there is no POM
    in this directory (c:\Web_Workspace). Please verify you invoked Maven from the
    correct directory. -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
    ch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please rea
    d the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProject
    Exception
    c:\Web_Workspace>

    I searched in Google and in few forums, its said that pom.xml is missing.
    Now this is not mentioned in any step to create .
    can you please suggest how to fix this ???

    Reply
  6. Kishore says:

    can please explain this cammand from the given above

    mvn archetype:create –DgroupId=com.itcuties –DartifactId=test
    
    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>