Fortunately found the solution myself. .First need to run flush() and close() method and then the second(named:-open) method. Inside open method, instead of R
Runtime.getRuntime().exec(cmd);
i expanded it into two lines:-
Runtime run = Runtime.getRuntime();
Run.exec(cmd);
Thats it..:D