Java with maven wouldn't build: Cannot run pro

2020-02-10 13:10发布

I've a fresh install of netbean 11.1. Now I'm trying to build a project but I get the following error output:

Cannot run program "cmd" (in directory "C:\projects\open"): Malformed argument has embedded quote: "C:\Program Files\NetBeans-11.1\netbeans\java\maven\bin\mvn.cmd"

cd C:\projects\open; "JAVA_HOME=C:\\Program Files\\Java\\jdk-11.0.5" cmd /c "\"\"C:\\Program Files\\NetBeans-11.1\\netbeans\\java\\maven\\bin\\mvn.cmd\" -DskipTests=true -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans-11.1\\netbeans\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 clean install\"" Cannot run program "cmd" (in directory "C:\projects\open"): Malformed argument has embedded quote: "C:\Program Files\NetBeans-11.1\netbeans\java\maven\bin\mvn.cmd" -DskipTests=true -Dmaven.ext.class.path="C:\Program Files\NetBeans-11.1\netbeans\java\maven-nblib\netbeans-eventspy.jar" -Dfile.encoding=UTF-8 clean install

I've build this project with netbeans 11.1 before but have a new pc. and a fresh install, tho I'm sure there was no problem last time I tried to install everything.

9条回答
爷、活的狠高调
2楼-- · 2020-02-10 13:51

I had the same problem with oracle jdk 13.0.1 and netbeans 11.1, but it worked for me with openjdk 13.0.1 (https://jdk.java.net/13/).

查看更多
Melony?
3楼-- · 2020-02-10 13:53

I had this error with adopt8-hotspot (AdoptOpenJDK-1.8.0_232-b09) and sbt-0.13.X for an old project.

Problem solved after setting the environment variable in windows via

set JAVA_TOOL_OPTIONS=-Djdk.lang.Process.allowAmbiguousCommands=true
查看更多
我欲成王,谁敢阻挡
4楼-- · 2020-02-10 13:56

Although this problem can be fixed by installing jdk1.8.0_221, but actually you don't need to downgrade your JDK. Just try these:

  • 1. First exit netbeans IDE if it's open, then open netbeans configuration file from here: netbeans-Install-Dir/etc/netbeans.conf (Note: for me netbeans-Install-Dir is C:\Program Files\NetBeans 8.2\etc)
  • 2. Add this '-J-Djdk.lang.Process.allowAmbiguousCommands=true' to the beginning of the string that you find at this line:
    netbeans_default_options="-J-client -J-Xss2m -J-Xms32m ......."
  • 3. Save the change and start your netbeans ide.
  • 查看更多
    登录 后发表回答