I'm pretty sure it's because you are trying to mix two ways of passing the arguments to
exec()
.
Try this:
Process process = Runtime.getRuntime().exec(new String[]{
"C:/cygwin/bin/bash",
"-c /usr/bin/gcc",
"/cygdrive/d/MyFile.c",
"-o /cygdrive/d/MyExe"});
or
Process process = Runtime.getRuntime().exec(
"C:/cygwin/bin/bash -c /usr/bin/gcc /cygdrive/d/MyFile.c -o /cygdrive/d/MyExe");
Cheers,
Peter