Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes problem in running  dos command  from  java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "problem in running  dos command  from  java" Watch "problem in running  dos command  from  java" New topic
Author

problem in running dos command from java

aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
Hi
i have wriiten a code for running command of DOS-Promt
try
{
rnt1 = Runtime.getRuntime();
proc1= rnt1.exec("myb");//myb is a batch file and proc1 is process class instance
try
{
proc1.waitFor();
}
catch (InterruptedException e)
{
System.out.println("InterruptedException raised: "+e.getMessage());
}

}

catch (IOException ioe)
{
System.out.println("IOException raised: "+ioe.getMessage());
}
But it is giving error while running:
this is showing as an IO exception
CreateProcess: myb error=0
Please help me how to proceed
Thanks


Regards<br />Aminur
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Try
Runtime.getRuntime().exec("cmd /K start myb.bat");


"JavaRanch, where the deer and the Certified play" - David O'Meara
aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
Originally posted by Cindy Glass:
Try
Runtime.getRuntime().exec("cmd /K start myb.bat");


Thanks but the programme ran by the following command
"start command /K myb.bat"
Thanks again for you valuable answer
Aminur
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem in running dos command from java