I'm new to Maven and I have downloaded the 3.0.5 version. I'm getting the following error:
JAVA_HOME is set to an invalid directory. please set the java_home variable in your environment variable to match the location of your java installation
Although, I see no error when I type javac
or echo %M2_HOME%
in the command prompt.
I have the following path variables set -
CLASSPATH - ;C:\Program Files (x86)\Java\jdk1.7.0_40\lib;
JAVA_HOME - C:\Program Files (x86)\Java\jdk1.7.0_40\bin
M2 - %M2_HOME%\bin
M2_HOME - C:\Users\cbil\Documents\Maven\apache-maven-3.0.5-bin\apache-maven-3.0.5
MAVEN_OPTS - -Xms256m -Xmx512m
PATH - C:\Program Files\Java\jdk1.7.0_45\bin;C:\Users\cbil\Documents\Maven\apache-maven-3.0.5-bin\apache-maven-3.0.5\bin;
Can someone please help me?
To set JAVA_HOME
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_40
To add
mvn
to pathset PATH=%PATH%;C:\Users\cbil\Documents\Maven\apache-maven-3.0.5-bin\apache-maven-3.0.5\bin;
JAVA_HOME should be set to jdk installation directory and not to the bin folder.
It should work, once the path is set properly.
Read the official documentation. The Maven Installation Instructions for Windows are pretty simple to follow.
Inside your system variables, set JAVA_HOME
and inside path, add these:
The error is caused due to non readability of the java path .
M2_HOME
points to the directory where maven is installed.M2
points to the bin directory under mavenJAVA_HOME
points to the JDK directory installed on your system.validate it again from below settings: