Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring Maven for Windows 7, Files\Java\jdk1.6.0_23"" was unexpected at this time error

I am trying to configure Maven on my Win 7 machine. I am following these steps: http://maven.apache.org/download.cgi I downloaded Maven into folder c:\Program Files\Apache Software Foundation\apache-maven-3.0.5\

I set all environmental variables as described in the URL above

JAVA_HOME = C:\Program Files\Java\jdk1.6.0_23
M2_HOME = c:\Program Files\Apache Software Foundation\apache-maven-3.0.5\
M2 = %M2_HOME%\bin
PATH = %M2%; C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;     %JAVA_HOME%\bin ; C:\Program Files\Java\jdk1.6.0_23

But when I enter: C:\Users\Andrei>mvn --version

I get a :

Files\Java\jdk1.6.0_23"" was unexpected at this time.

Can you please help me with this issue? Let me know please if you need more details. Thanks in advance!

like image 723
Andrei Avatar asked Mar 13 '13 17:03

Andrei


4 Answers

This one solved it for me: http://www.xinotes.net/notes/note/559/

It is a problem with how the JAVA_HOME path is being set.

Set the path without quotes like this:

set java_home=c:\Program Files\Java

Or using the 8 char syntax for folder names like this:

set java_home="c:\Progra~1\Java"
like image 76
JHP Avatar answered Nov 23 '22 12:11

JHP


To solve the same issue

I did:

SET M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-3.2.3-bin\apache-maven-3.2.3

Then

SET JAVA_HOME=C:\Program Files (x86)\Java\jre7

And finally I added to the beginning of Path

SET Path=%JAVA_HOME%\bin;%M2_HOME%\bin;...

After exiting all my running cmd.exe and opened a new one I was able to do mvn --version with no problems.

like image 21
ThelmaJay Avatar answered Nov 23 '22 12:11

ThelmaJay


I had the same problem, but the cause was M2_HOME variable defined as:

C:\apache-maven-3.2.2\bin

instead of

C:\apache-maven-3.2.2\

Also the JAVA_HOME should be to the java folder, and not to the \bin sub-folder.

like image 33
Lior Bar-On Avatar answered Nov 23 '22 11:11

Lior Bar-On


I ran into a similar issue and the problem is with the presence of character "(" in the current directory path where maven is being run eg:- C:\Work(test)\Java-Project. I simply changed it to C:\Work\Java-Project and its working fine now.

For info I'm running Windows 10 with Maven V3.6.0

like image 40
Ganesh Pendyala Avatar answered Nov 23 '22 12:11

Ganesh Pendyala