Windows executing bat/cmd

Bernd Eckenfels ecki at
Sun Oct 5 02:12:31 UTC 2014

Am Sat, 04 Oct 2014 18:21:58 -0700
schrieb Alan Bateman <Alan.Bateman at>:
> It's for compatibility reasons. There is a lot of code that calls 
> Runtime.exec to run .cmd and .bat scripts. Early versions of the JDK 
> didn't do much validation in this area and just passed the input to
> the win32 call. The checking has been tightened up a lot since and
> part had to deal with compatibility and keeping existing applications
> working.

This creates the interesting situation, that the JVM verifies stricter
if you not use the (Microsoft recommended) "cmd /C". (In fact the
implementation even documents this as a workaround if you want to
avoid the validation.)

Would it make sense to officially describe this in the exec(String[]),
that you can specify the path to a bat/cmd file as the first argument
and do not need to use the cmd /c?


More information about the core-libs-dev mailing list