| Author |
Running Batch Files
|
Amit Lonkar
Greenhorn
Joined: Dec 12, 2001
Posts: 25
|
|
Hi All!!! Can anyone tell me how to run ".bat" files from Java. Currently I am using Runtime.exec("c:\\TestBat.bat"); But this does not work. Amit
|
 |
Arun Boraiah
Ranch Hand
Joined: Nov 28, 2001
Posts: 233
|
|
Can you tell what was the error displayed. try this 1. Check the presence of file name 2. File name case -arun
|
Sharing is learning
|
 |
Matt Siegel
Ranch Hand
Joined: Jul 18, 2000
Posts: 55
|
|
Hi Amit, You are going to want to use the Runtime.exec(String[] cmdarray) method. Here's some code: But remember you won't see any output from the batch file on the command line when it is run. You will need to grab the streams from the Process object. HTH, Matt
|
 |
Amit Lonkar
Greenhorn
Joined: Dec 12, 2001
Posts: 25
|
|
Hi I tried Running the batch file as := String[] cmds = {"cmd", "/c", "c:\\TestBat.bat"}; Process proc = Runtime.getRuntime().exec(cmds); The program runs. But does not show the command prompt. Thanks Amit
|
 |
Amit Lonkar
Greenhorn
Joined: Dec 12, 2001
Posts: 25
|
|
Sorry I did not see the last line. Trying it out... Thanks Amit
|
 |
 |
|
|
subject: Running Batch Files
|
|
|