I would say this is happening because you are calling your main method from within your main method hence a stack overflow.
Try removing the last couple of lines of code.
Java Code
automation1.main(args);
if(chld.length==0)
{
automation1.main(args);
}
// Json