Netbeans 9/10/11 cannot run program "cmd"

43,030

Solution 1

No need to downgrade the JDK, just add this in your netbeans.conf

  1. Find your netbeans.conf file. e.g.: netbeansIstallDir/etc/netbeans.conf

  2. Find the key netbeans_default_options and at the start of the string add the following: -J-Djdk.lang.Process.allowAmbiguousCommands=true

    It should look like this:

    netbeans_default_options="-J-Djdk.lang.Process.allowAmbiguousCommands=true..."
    

Solution 2

Fixed this issue by installing jdk1.8.0_221 as suggested here:

Java with maven wouldn't build: Cannot run program "cmd" "Malformed argument has embedded quote"

Hope this will help you too

Solution 3

No need to downgrade to an older JDK version, check my answer at https://stackoverflow.com/a/58484737 for a solution and the background of the change.

Solution 4

Find the key netbeans_default_options and at the start of the string add the following: -J-Djdk.lang.Process.allowAmbiguousCommands=true

It should look like this:

netbeans_default_options="-J-Djdk.lang.Process.allowAmbiguousCommands=true..."

this if form Omer Erden, congrats...

Share:
43,030
Ross P.
Author by

Ross P.

Recent IT graduate, hopeful future security analyst

Updated on December 31, 2020

Comments

  • Ross P.
    Ross P. over 3 years

    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 Project button, the output window shows the command:

    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

    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.

  • Ross P.
    Ross P. over 4 years
    Could you please share where you got the 221 update from? I can only find 231.
  • Andreas Vikke
    Andreas Vikke over 4 years
  • Ross P.
    Ross P. over 4 years
    Thanks so much. This solved my problem. Guessing update 231 changes how quotes are escaped or something.
  • Ross P.
    Ross P. over 4 years
    Download jdk1.8.0_221. This solved my issue. I assume update 231 breaks something with escaping quotes.
  • Ryan Russell
    Ryan Russell over 4 years
    What is this doing exactly? Am I making Netbeans less secure/stable by allowing ambiguous commands?
  • Jake Gaston
    Jake Gaston over 4 years
    Might be a no-brainer, but just wanted to add, restart netbeans after doing this.