Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Installation under Windows: "JAVA_HOME is set to an invalid directory" [duplicate]

Tags:

java

maven

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?

like image 929
user2006189 Avatar asked Jun 12 '14 14:06

user2006189


1 Answers

  • M2_HOME points to the directory where maven is installed.
  • M2 points to the bin directory under maven
  • JAVA_HOME points to the JDK directory installed on your system.

validate it again from below settings:

JAVA_HOME   - C:\Program Files\Java\jdk1.6.0_23
M2_HOME     - D:\Software\apache-maven-3.0.5
M2          - %M2_HOME%\bin
PATH        - %M2%;%JAVA_HOME%\bin
like image 105
Braj Avatar answered Sep 19 '22 12:09

Braj