| Author |
How To Run .bat file from java application
|
Sachin Dimble
Ranch Hand
Joined: Dec 07, 2005
Posts: 100
|
|
Can anybody suggest on this??? I know how to run .exe using processbuilder... Thanx in Advance Sachin!!!
|
 |
Arun Boraiah
Ranch Hand
Joined: Nov 28, 2001
Posts: 233
|
|
You can execute application from java using Runtime object. Find the sudo code below. Runtime rtObj =Runtime.getRuntime() rtObj.exec("appl.exe");
|
Sharing is learning
|
 |
Sunil Kumar Gupta
Ranch Hand
Joined: Aug 26, 2005
Posts: 824
|
|
//java source import java.io.*; public class MyRun { public MyRun() { Runtime runtime = Runtime.getRuntime(); String[] cmd = {"cmd","/c","abc.bat"}; try{ Process p =runtime.exec(cmd); BufferedReader b =new BufferedReader(new InputStreamReader(p.getInputStream())); String line=null; while( (line=b.readLine())!=null) { System.out.println(line); } } catch(Exception e) { e.printStackTrace(); } } public static void main(String args[]) { MyRun r =new MyRun(); } }
|
Lack of will power has caused more failure than lack of intelligence or ability.
My Blog | Red5 Resources | Technology Update | Daily Technology Tips
|
 |
Sachin Dimble
Ranch Hand
Joined: Dec 07, 2005
Posts: 100
|
|
Thanx Arun,Sunil for u r valuable suggestion. Sachin!!!
|
 |
 |
|
|
subject: How To Run .bat file from java application
|
|
|