views:

278

answers:

1

I'm about to work through a book, "Flex on Java" and it's asked me to install maven 2+ i downloaded maven from the apache site. Added :

M2_HOME = C:\apache-maven-2.2.1

and

M2 = %M2_HOME%\bin

to the environment vars according to the instructions at http://maven.apache.org/download.html then it gets to number 6 which says "In the same dialog, update/create the Path environment variable in the user variables and prepend the value %M2% to add Maven available in the command line."

Which environment variable should i edit and add %M2% to?

After googling i found a post which says "append", not prepend to the value of JAVA_HOME I've tried prepending and appending it to the java home var but when i try to do an mvn command from the command line it says its not recognised.

Never used maven before so this is my first set up. Can anyone see what i'm not doing right or what else i need to do to be able to use the mvn command, please and thank you.

+1  A: 

The environment variable you should edit is path.

The route on Windows 7 is:

Control Panel -> System -> Advanced system settings -> Advanced Tab -> Environment Variables -> The path variable is right on the *system variable*s area

The path variable specifies a group of directories and/or paths that Windows searches for commands definitions. You should append to the end of this variable value the value ;%M2% (note the semi-colon, different paths should be separated by them) in order for Windows to be able to find the Maven command definitions.

Appending ;%M2 at the end of the path environment variables is the same as appending ;C:\apache-maven-2.2.1\bin

To test that everything is ok, type mvn --version, if everything is right then the current Maven version you're using should be displayed on the screen.

StudiousJoseph
Ahhhhhhhhhhh, thank you.I was focusing on the user env. vars and kept misreading that so i didn't realise it meant the system path var. thanks again.
robinsonc494