• Post Reply Bookmark Topic Watch Topic
  • New Topic

Maven Newbie: Unable to generate first project on Windows command line  RSS feed

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm new to maven and have just installed maven 3.3.1 on my windows 7 computer.

I've followed the download and installation instructions given here.

From my research on google / the web, I've setup the maven environment variables [by right-clicking my computer > properties >
advanced system settings > System properties > Advanced tab > Environment variables and under System variables] as

I've appended the java and maven bin directories [separated by semi-colon] at the end of the System variable, Path .

From the getting-started-guide-apache-maven-in-5-minutes page, I've also verified maven installation by

by opening the command prompt window and entering the mvn --version command which shows its successful installation.

However, when I tried to generate the first maven project [quintessential Hello World program] from another directory with
archetype:generate command, I'm getting the following

instead of the jars being downloaded from the maven central repo & the project being built. Naturally, on checking E drive, neither the
project directories (and their paths) nor the m2 [local repo] folder been constructed.


Again, looking closely here led me to these windows prerequisites vis-a-vis installing maven on windows O.S. As maven is java-based,
the windows prerequisites requires
both java and maven to be installed in directory paths that do not have spaces inbetween them. While my maven installed directory
D:\apache-maven-3.3.1 conforms, the jdk installed directory is C:\Program Files\Java\jdk1.8.0_40 [i.e Program Files contains space inbetween].

Other details:
O.S: Windows 7 64-bit
Java installed:
  • x64 for 64-bit O.S Path: C:\Program Files\Java\jdk1.8.0_40
  • x86 for 32-bit browsers [firefox, chrome, IE] for running applets and other 32-bit compatible apps Path: C:\Program Files (x86)\Java\jdk1.8.0_40 .

  • JAVA_HOME: points to the x64 jdk installed directory

    Why is it I'm unable to build the project from the command prompt? Is it because of
    a) the jdk location [i.e being installed in Program files] and / or
    b) existence of two jdk's [32-bit & 64-bit]......my research on the web shows a) and b) are perfectly OK vis-a-vis java download and installation
    c) any other reason I'm missing

    Much appreciated if any of the forum experts help me in resolving this [without, hopefully, advocating change in java jdk setup].

    Thanks,
    Sudhir

     
    Rancher
    Posts: 2762
    32
    Eclipse IDE Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    This is probably happenning because it's either picking a differrent maven or a differrent java in it's path when you run from the 2 seperate places. Windows can get confusing sometimes. Also, in windows when you change environment variables, you need to restart command prompt to get the new variables. If you change system variables in Control panel, then alt_tab to a command prompt, the command prompt will still have old variables. There's a reason why people who like command line hate windows, and this is where it starts.


    Anyhoo do this: First of all close all your command prompts. Just close them. And open a new one. Then run mvn --version and java -version in both folders and then post back what you get. That will help you solve the problem. If they are both same, then maven should run same in both locations



     
    Sudhir Srinivasan
    Ranch Hand
    Posts: 93
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi,

    Thank you for your response.

    Jayesh A Lalwani wrote:
    Anyhoo do this: First of all close all your command prompts. Just close them. And open a new one. Then run mvn --version
    and java -version in both folders and then post back what you get.


    Per your recommendation, I closed the command prompt restarted the system and opened a new one. On running java -version
    and mvn --version in respective directories

    the results appear to be the same.

    On running the generate command following maven lib jars (have not reproduced the download
    in order to keep my post short)


    downloaded from central repo to local repo (.m2 folder created) on successful execution of generate
    from the command line and

    also the successful creation of the first project.

    This once again downloads all the maven lib plugins required for packaging the project (my-app)

    and the successful jar file generation at the location

    Tested the newly compiled and packaged (project) JAR

    to get the output


    This certainly solves the issue at hand. Many thanks Jayesh!

    [sidebar]

    This has installed the my-app project within the maven installed directory. How does one create the project
    outside the maven directory?
    [/sidebar]

    Sudhir
     
    Jayesh A Lalwani
    Rancher
    Posts: 2762
    32
    Eclipse IDE Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    When you create the project, run the archetype:generate in the folder that you want to generate the project in

    FOr not you can just copy the myapp folder where you want it to go. It should still work
     
    Sudhir Srinivasan
    Ranch Hand
    Posts: 93
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Jayesh A Lalwani wrote:
    FOr not you can just copy the myapp folder where you want it to go. It should still work


    As suggested, copied the my-app directory to the folder of my choice i.e E: . Then in the command prompt

    switched to the folder concerned and ran the project successfully. So, simply copy pasting the project does work!

    While your latter suggestion worked, the former

    Jayesh A Lalwani wrote:
    When you create the project, run the archetype:generate in the folder that you want to generate the project in


    one resulted in the same output (that I encountered initially), namely,


    So, I switched to the maven installed directory

    and ran the archetype:generate command

    to successfully

    build (using the maven lib jars from the installed local repo) and execute the project.

    To Summarise:
    a) I'm able to copy paste existing project from maven dir to folder of my choice i.e E: and execute the project
    AND
    b) I'm able to build (& execute) a new project from within the maven installed directory (as shown above)
    BUT UNABLE
    c) to build a new project in a folder, E:, distinct from the maven installed directory. What gives???

    Could you please explain and also help resolve this confusion.

    FYI again:
    JDKs installed -
    Path: C:\Program Files\Java\jdk1.8.0_40 (for 64-bit O.S)
    Path: C:\Program Files (x86)\Java\jdk1.8.0_40 (for 32-bit browsers)

    Maven installed dir -
    D:\apache-maven-3.3.1

    Many Thanks,
    Sudhir
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!