Is this a bug with Java? Is this a bug with Windows?
This is a mistake in your code. :-)
By default, a child process created using the ProcessBuilder object has an output redirected to a pipe whose parent end can be obtained using Process.getInputStream() and which will not be automatically merged if your code does not use it.
Since your code simply calls .waitFor , without creating any conditions for draining the pipe, it will be blocked as soon as the buffer is full. I believe the default buffer size is 4096 bytes. On my machine, the output of the command you are using is 5,192 bytes, but this will depend on the original contents of the environment block. (Of its sounds, the output length in your environment is limited, only slightly above the limit, so even small changes, such as changing the VS version, matter.)
One of many possible solutions, depending on what you are actually trying to do, is to tell Java not to output the output file:
import java.io.IOException; public class StrangeError { public static void main(String[] args) { try { ProcessBuilder processb = new ProcessBuilder( "cmd", "/c", "\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat\" amd64 && set" ); processb.redirectOutput(ProcessBuilder.Redirect.INHERIT); Process process = processb.start(); process.waitFor(); } catch (IOException|InterruptedException e) { System.out.println(e.getMessage()); } } }
source share