简体   繁体   中英

Maven - “files was unexpected at this time”

I'm trying to install maven to my PC.(windows 7)

Following are the steps I have done.

1. Installed Java 1.8.0.11
2. Added a system variable JAVA_HOME = C:\Program Files\Java\jdk1.8.0_11
3. Appended it to the path -  PATH=%JAVA_HOME%\bin;C:\Program Files\......;... etc
4. Typed "Java -version" in command line and got the java version details as usual.
5. Then I downloaded and extracted the Maven 3.3.3 
6. Added the M2_HOME to system variable.M2_HOME=C:\Program Files\apache-maven-3.3.3\apache-maven-3.3.3
7. Added M2 Variable  M2=%M2_HOME%\bin
8. Appended M2 to Path variable. PATH=%M2%;%JAVA_HOME%\bin;....;...etc
9. Typed mvn --version in command line.

Get the following error.

Files was unexpected at this time.

What is wrong here? Please help me to get this resolved.

Thanks in advance!

**Note - I have not use quotes for any of the paths here. also I tried with 8 char syntax for folder names like this:

set java_home="c:\\Progra~1\\Java"

Non of these were resolved the issue. Please read the steps I have added and help me to get this resolved.**

Finally I was able to resolved the issue.

A quoted value in the user variables has caused to the "Files were unexpected at this time" error in maven.

I spent hours of time with changing Java_home and M2_home variables with different combinations but finally checked the user variable and noted the quotes there.

Home = "C:\Program Files (x86)\Git\bin"

Removed the quotes and change the git home variable as below and now all works fine. :)

Home = C:\Program Files (x86)\Git\bin

这就是错误所在

I had a similar issue
Files\\apache-maven-3.3.9""=="" was unexpected at this time.
and when looking at "Environment Variables" inside "System Properties" there were no quotes (") inside of any variables, but before doing that I was following a tutorial and set those values via cmd:
C:\\Program Files\\apache-maven-3.3.9\\bin>set M2_HOME="C:\\Program Files\\apache-maven-3.3.9"
So, in order to fix it I just re-run the following in cmd:
C:\\Program Files\\apache-maven-3.3.9\\bin>set M2_HOME=C:\\Program Files\\apache-maven-3.3.9
(removed " from cmd assignment) I hope this helps someone.

Try adding

C:\Program Files\apache-maven-3.3.3\apache-maven-3.3.3\bin

to PATH variable

I was facing same issue in jenkins when I asked jenkins to install maven internally. Notice double quotes below when jenkins was firing a build

 '""C:\Program Files (x86)\Jenkins\tools\hudson.tasks.Maven_MavenInstallation\maven\bin\mvn.cmd"' -f ./Voyager/pom.xml clean package....

To resolve this I downloaded maven and manually set the path in jenkins and it was resolved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM