2
votes

I am using Netbeans 7.4. I down loaded the Maven3.1 and extracted in C:\Apache\apache-maven-3.1.1. System Variables are set as :

JAVA_HOME is set at C:\Program Files\Java\jdk1.7.0_45 M2_HOME is set to C:\Apache\apache-maven-3.1.1

Path is set to C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.7.0_45\bin;%M2_HOME%\bin

Now when from the command line I command ..>mvn -v I get this this error:

ERROR: JAVA_HOME is set to an invalid directory. JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_45;" Please set the JAVA_HOME variable in your environment to match the location of your Java installation

5
what is the output of echo %JAVA_HOME%? how did you set JAVA_HOME? It has a semicolon at the end that shouldn't be there.JB Nizet
JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_45;" - you have ";" at the end - that seems to be wrongViktor K.
Its resolved by setting on Netbean->Tools->Options->Java-> and setting MavenHome.javaz
@Nizet Output of echo %JAVA_HOME% is C:\Program Files\Java\jdk1.7.0_45.javaz

5 Answers

4
votes

Actually you need to create


system variable like this:
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_45
CLASS_PATH = C:\Program Files\Java\jdk1.7.0_45\bin\lib

User variable
ME = C:\Program Files\apache-maven-3.1.1\bin
M2_HOME = C:\Program Files\apache-maven-3.1.1
MAVEN_OPTS = -Xms256m -Xmx512m

Path - insert into your path
C:\Program Files\apache-maven-3.1.1\bin

Don't forget to reboot system

3
votes

Read the error message carefully. It says:

... JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_45;" ...

See the stray semicolon? Get rid of it!

The JAVA_HOME variable should contain a directory name ... not a "search path". What you are telling Maven to do is to use a directory whose name contains a semicolon. That directory doesn't exist.


Meta-advice: it pays to read error messages carefully.

1
votes

I faced the similar situation. I resolved it by removing the semicolon(;) at the end of JAVA_HOME.

JAVA_HOME = C:\Program Files\Java\jdk1.7.0_11

Instead of

JAVA_HOME = "C:\Program Files\Java\jdk1.7.0_11;"
0
votes

Java\jdk* is the installation directory of the development kit. Find a "jre" folder inside Program Files\Java. That "JRE" folder should be your JAVA_HOME

0
votes

The value JAVA_HOME should not contain quotes, because several Maven plugins will append something like 'bin\javac.exe', which would give an invalid path if the quotes are still there.