Java Netbeans 9/10/11 无法运行程序“cmd”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/58445540/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Netbeans 9/10/11 cannot run program "cmd"
提问by Ross
I unzipped NetBeans 11 to C:\netbeans
, installed several versions of the JDK to C:\java
and created a test class within NetBeans containing a main method and one line of code System.out.print("hello world");
. When I click the Run Projectbutton, the output window shows the command:
我将 NetBeans 11 解压缩到C:\netbeans
,安装了多个版本的 JDK,C:\java
并在 NetBeans 中创建了一个包含一个主要方法和一行代码的测试类System.out.print("hello world");
。当我单击“运行项目”按钮时,输出窗口会显示以下命令:
cd C:\Users\MyUsername\Documents\NetBeansProjects\asdf;
JAVA_HOME=C:\Java\jdk1.8.0_231 cmd /c "\"\"C:\netbeans-9\java\maven\bin\mvn.cmd\"
-Dexec.args=\"-classpath %classpath com.mycompany.asdf.Test\"
-Dexec.executable=C:\Java\jdk1.8.0_231\bin\java.exe
-Dmaven.ext.class.path=C:\netbeans-9\java\maven-nblib\netbeans-eventspy.jar
-Dfile.encoding=UTF-8 process-classes org.codehaus.mojo:exec-maven-plugin:1.5.0:exec\""
followed by the error:
其次是错误:
Cannot run program "cmd" (in directory "C:\Users\MyUsername\Documents\NetBeansProjects\asdf"): Malformed argument has embedded quote: "C:\netbeans-9\java\maven\bin\mvn.cmd" -Dexec.args="-classpath %classpath com.mycompany.asdf.Test" -Dexec.executable=C:\Java\jdk1.8.0_231\bin\java.exe -Dmaven.ext.class.path=C:\netbeans-9\java\maven-nblib\netbeans-eventspy.jar -Dfile.encoding=UTF-8 process-classes org.codehaus.mojo:exec-maven-plugin:1.5.0:exec
无法运行程序“cmd”(在目录“C:\Users\MyUsername\Documents\NetBeansProjects\asdf”中):格式错误的参数已嵌入引号:“C:\netbeans-9\java\maven\bin\mvn.cmd” - Dexec.args="-classpath %classpath com.mycompany.asdf.Test" -Dexec.executable=C:\Java\jdk1.8.0_231\bin\java.exe -Dmaven.ext.class.path=C:\netbeans -9\java\maven-nblib\netbeans-eventspy.jar -Dfile.encoding=UTF-8 process-classes org.codehaus.mojo:exec-maven-plugin:1.5.0:exec
Whether the class creates a GUI or not, it gives the same error. I've tried NetBeans 9, 10, and 11 with JDK 7, 8, and 11. Am I missing something during setup, or do I have something in a wrong directory somewhere? I'm lost.
无论该类是否创建 GUI,它都会给出相同的错误。我已经在 JDK 7、8 和 11 上尝试过 NetBeans 9、10 和 11。我在安装过程中是否遗漏了什么,或者我在某个地方的目录中有什么错误?我迷路了。
采纳答案by Pascal Fares ENT Cnam Liban
No need to downgrade the JDK just add this in your netbeans.conf
无需降级 JDK 只需将其添加到您的 netbeans.conf 中
Find your netbeans.conf file netbeansIstallDir/etc/netbeans.conf
找到您的 netbeans.conf 文件 netbeansIstallDir/etc/netbeans.conf
Find the key netbeans_default_options
and at the start of the string add the following: -J-Djdk.lang.Process.allowAmbiguousCommands=true
找到键netbeans_default_options
并在字符串的开头添加以下内容:-J-Djdk.lang.Process.allowAmbiguousCommands=true
It should look like this:
它应该是这样的:
netbeans_default_options="-J-Djdk.lang.Process.allowAmbiguousCommands=true..."
回答by Andreas Vikke
Fixed this issue by installing jdk1.8.0_221 as suggested here:
通过按照此处的建议安装 jdk1.8.0_221 来解决此问题:
Java with maven wouldn't build: Cannot run program "cmd" "Malformed argument has embedded quote"
使用 Maven 的 Java 不会构建:无法运行程序“cmd”“格式错误的参数已嵌入引号”
Hope this will help you too
希望这也能帮助你
回答by hareti
I'm having the same "Malformed argument has embedded quote:" error when trying to run any project. Netbeans 11.0 and I've tried jdk13.0.1 jdk11.0.5 and jkd1.8.0 all with the same error. I'm at a loss too.
我在尝试运行任何项目时遇到相同的“格式错误的参数已嵌入引号:”错误。Netbeans 11.0 和我试过 jdk13.0.1 jdk11.0.5 和 jkd1.8.0 都出现相同的错误。我也很茫然。
回答by Sephiroth
No need to downgrade to an older JDK version, check my answer at https://stackoverflow.com/a/58484737for a solution and the background of the change.
无需降级到较旧的 JDK 版本,请在https://stackoverflow.com/a/58484737 上查看我的答案以获取解决方案和更改背景。
回答by Francisco
Find the key netbeans_default_options and at the start of the string add the following: -J-Djdk.lang.Process.allowAmbiguousCommands=true
找到键 netbeans_default_options 并在字符串的开头添加以下内容:-J-Djdk.lang.Process.allowAmbiguousCommands=true
It should look like this:
它应该是这样的:
netbeans_default_options="-J-Djdk.lang.Process.allowAmbiguousCommands=true..."
netbeans_default_options="-J-Djdk.lang.Process.allowAmbiguousCommands=true..."
this if form Omer Erden, congrats...
这如果形成 Omer Erden,恭喜...