Got IOException CreateProcess error=2, The system cannot find the file specified
<p>I am new to <code>ProcessBuilder</code>. Today I am writing a simple application to execute the "java -version" but always got the <code>IOException</code>.</p>

<pre><code>ProcessBuilder pb = new ProcessBuilder("java -version");
        try {
            Map&lt;String, String&gt; map = pb.environment();  
            Process p  = pb.start();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
</code></pre>

<p>The exception thrown as below </p>

<pre><code>java.io.IOException: Cannot run program "java -version": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
</code></pre>

<p>I can ensure that <code>JAVA_HOME</code> is set in environment variable, my eclipse is pointing to the jdk too.</p>

<pre><code>JAVA_HOME=C:\JDK1.8.0_66-X64.
</code></pre>

<p>Can anyone tell what the problem is in my code/settings ? </p>