i am using Runtime.getRuntime().exec() command in Java to start a batch file which in turn starts another process for windows platform.
javaw.exe(Process1) |___
With java 9, killing the main process kills the whole process tree. You could do something like this:
Process ptree = Runtime.getRuntime().exec("cmd.exe","/c","xyz.bat"); // wait logic ptree.destroy();
Please take a look at this blog and check out the Deal with Process Trees example.