• Post Reply Bookmark Topic Watch Topic
  • New Topic

invoking a batch file from java code  RSS feed

 
Srikrishna DhumalRao
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a scenario where i have to "invoke a batch file which internally invokes ant" from a java program.I used
Runtime proc= Runtime.getRuntime();
Process process=proc.exec("cmd /c <batch file path>");
process.waitFor();

it is not opening a new command prompt window and also the batch file is not being processed. Can any one throw light in this aspect.

Thanks in Advance.
 
Pradeep Kadambar
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the following code will ensure the execution of the batch file unless a proper path is not provide.



Ensure the execution of the batch by running it first in command prompt and then try with the program. You never know what errors are thrown.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!