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].
O.S: Windows 7 64-bit
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].
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
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!
This has installed the my-app project within the maven installed directory. How does one create the project
outside the maven directory?
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
build (using the maven lib jars from the installed local repo) and execute the project.
a) I'm able to copy paste existing project from maven dir to folder of my choice i.e E: and execute the project
b) I'm able to build (& execute) a new project from within the maven installed directory (as shown above)
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.
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 -
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
Rocket Oven Kickstarter - from the trailbosshttps://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss