Maven and Java_Home
Solution 1
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
Solution 2
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.
Solution 3
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;"
javaz
Updated on June 04, 2022Comments
-
javaz almost 2 years
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
-
Viktor K. over 10 yearsjdk is superset of jre, maven requires jdk
-
Marcos over 10 years@javaz, create your environment as I told you and you got it. I could it and don't bother with lazy guys who are just downgrading votes.