Maven - “files was unexpected at this time”

2020-07-06 03:53发布

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.**

标签: java maven
4条回答
别忘想泡老子
2楼-- · 2020-07-06 04:18

Try adding

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

to PATH variable

查看更多
我命由我不由天
3楼-- · 2020-07-06 04:28

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.

查看更多
够拽才男人
4楼-- · 2020-07-06 04:30

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.

查看更多
欢心
5楼-- · 2020-07-06 04:34

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

This is where the error was

查看更多
登录 后发表回答