Reputation: 587
I'm trying to install Maven in order to run selenium junit test and then integrate it in Jenkins
When I run in CMD : mvn -version
, I have this:
Error: JAVA_HOME is set to an invalid directory.
JAVA_HOME = "C:\Program Files\Java\jdk1.8.0_11\bin"
Please set the JAVA_HOME variable in your environnement to match the
location of your Java installation.
When I run java -version
, I have this:
java version "1.8.0_20"
Java(TM) SE Runtime Environment (Build 1.8.0_20-h26)
Java HotSPot(TM) 64-Bit Server VM (build 25.20-h23, mixed mode)
Why do I get this error?
Here is my configuration for java and maven
I have Windows 7 64bits
I installed Maven here
C:\Program Files\Apache Software Foundation\apache-maven-3.2.3
For java, I have installed these version:
C:\Program Files\Java\jdk1.6.0_37 should i keep this version?
C:\Program Files\Java\jdk1.7.0_60 should i keep this version?
C:\Program Files\Java\jdk1.8.0_11
C:\Program Files\Java\jre1.8.0_20
C:\Program Files\Java\jre6
C:\Program Files\Java\jre7
In User variable, I have this:
JAVA_HOME
C:\Program Files\Java\jdk1.8.0_11\bin
MAVEN_OPTS
%M2%
PATH
C:\Program Files\Java\jdk1.8.0_11\bin;
in System variable, I have this:
JAVA_HOME
C:\Program Files\Java\jdk1.8.0_11\bin
JRE_HOME
C:\Program Files\Java\jre6;
M2
%MAVEN_HOME%\bin;
MAVEN_HOME
C:\Program Files\Apache Software Foundation\apache-maven-3.2.3;
Path
C:\Program Files\Apache Software Foundation\apache-maven-3.2.3\bin;C:\Program Files\Java\jdk1.8.0_11\bin;
Upvotes: 1
Views: 6717
Reputation: 587
PLease go to http://dbc-customs.com/?p=96
1. Download and install Java JDK (minimum 1.7) Jave SE downloads
2. Download Maven Binary from Apache from the Maven Downloads Page or use this direct link for Maven 3.2.1 (Binary zip)
3. Extract zip file to C:\Program Files (x86)\ApacheMaven\apache-maven-3.2.1 (Note: if you select a different directory, please update following steps accordingly)
4. Open the “Environment Variables” in Windows. (WinKey + Pause/Break) > Advanced System Settings > Advanced tab > “Environment Variables…” Button.
5. Add the following variables to the “System variables” section. (Not the “User variables”)
JAVA_HOME
C:\Program Files\Java\jdk1.7.0_51
M2_HOME
C:\Program Files (x86)\ApacheMaven\apache-maven-3.2.1
M2
%M2_HOME%\bin
6. Open the “Path” variable in the System variables section, and add the following at the end of your Path:
;%M2%;%JAVA_HOME%\bin
Note: the semicolon ( ; ) is used to separate values.
7. Open a new command prompt (Winkey + R then type cmd) and run mvn --version
to verify that it is correctly installed.
C:\Users\curtis>mvn --version
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T10:37:52-07:00)
Maven home: C:\Program Files (x86)\ApacheMaven\apache-maven-3.2.1
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_51\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Upvotes: 1
Reputation: 577
Your configuration should be:
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_11
M2_HOME = C:\Program Files\Apache Software Foundation\apache-maven-3.2.3
Then in your PATH add:
;%JAVA_HOME%\bin;%M2_HOME%\bin
If you need an explanation check this:
Upvotes: 0
Reputation: 4814
Please set the JAVA_HOME variable in your environnement to match the
location of your Java installation. This is clearly saying that your value to JAVA_HOME is wrong.
Change your JAVA_HOME with following value.
JAVA_HOME = "C:\Program Files\Java\jdk1.8.0_11"
PATH and JAVA_HOME are two different environment variables.
JAVA_HOME is java installation directory.
Where as PATH for Java is location of javac.exe,java.exe like executables so it is upto %JAVA_HOME%bin.
Upvotes: 4
Reputation: 11
set JAVA_HOME to C:\Program Files\Java\jdk1.8.0_11 without the \bin and in the path put %JAVA_HOME%\bin
Upvotes: 1