Friday, 12 February 2016

How to set Maven classpath in Windows

How to set Maven classpath in Windows
Setting Apache Maven classpath in Windows:

Before development in Maven we need to set the following classpath JAVA_HOME, MAVEN_HOME, PATH.

Step 1:
Start button -> My Computer-> Right Click-> Properties -> Advanced System Settings -> Advanced tab in System Properties dialog -> Environment Variables button -> System variables


How to set Maven classpath in Windows

Step 2:

How to set Maven classpath in Windows

Click on the "New" button to add environment variables.

Step 3:
Set the  JAVA_HOME variable.
It should point to the JDK path just above the "bin" directory like shown below.
How to set Maven classpath in Windows

Step 4:
Set the M2_HOME variable.
It should point to the directory one level above the "bin" directory.
How to set Maven classpath in Windows

Step 5:
Set M2 variable.
How to set Maven classpath in Windows


Step 6:
Set the Path variable.
You may already have a variable with the name "Path".
Search for it in the list of variables.
How to set Maven classpath in Windows


If you don't see a path variable then hit the "New" button and create a new variable like below.
How to set Maven classpath in Windows

Add this at the end of the text after a semicolon (;)
%M2%;%JAVA_HOME%

Step 7:
Open a command prompt by going to the Start Menu and typing in "cmd". Hit Enter.
How to set Maven classpath in Windows


Step 8:
Type the command "mvn -version" and hit enter.
If you have done all the above steps correctly then you will be able to see something like this.
How to set Maven classpath in Windows


Congratulations...!! Now you have successfully set the Maven path.



No comments:

Post a Comment

Coder Magnet
CoderMagnet is full of resources from our daily development activities. It has solutions for common problematic scenarios in technologies like Java 8, AEM, JCR and also occasionally gives you tips on Blogger as well.