I am calling a batch file from the main method in the following way:
public static void main(String args[]){
Runtime rt=Runtime.getRuntime();
try {
Process pr=rt.exec("D:\\test1.bat");
pr.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
The content of the batch file is as follows:
xcopy d:\a1 d:\a2
call C:\Java\jdk1.6.0_27\bin\java.exe -version >log1.txt 2>&1
Upon execution files from folder a1 are getting copied to folder a2, but the log1.txt is not getting generated. However if I double click this batch file, files are getting copied and the log1.txt is getting generated with the version of java.