This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Its not working
Posted by sravan kumar on October 05, 2001 at 12:56 AM
hi all i tested the above program and in my batch file the content is exp userid =DEVISS/DEVISS@ISSUAT file=DEVISSbeforeeod_161792001.dmp rows=n indexes=y that above command is to take the backup.. and by oracle8i database is on sunsolaris and iam ececuting from winnt.. as usual iam not getting any window it just hangs.. any suggentions pl advice.. i used the same code only content of Batch file is diffrent.. Thanx in advance > hi all, > try the following code works perfectly to run a batch file. and one more thing is you need not kill the dos prompt it automatically exits at the completion of your program execution . > I tested and it worked. All the best!! > Sarada Prapoorna.V > Goldstone Technologies LTD,Secunderabad,India.
> > import java.io.*; > > public class RunBatch > { > public static void main(String args[]) { > try { > Process p = Runtime.getRuntime().exec("batchfile.bat"); > > BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); > BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(p.getOutputStream())); > > bw.write("1"); > bw.flush(); > String line; > while ((line = br.readLine()) != null) { > System.out.println(line); > } > br.close(); > bw.close(); > > System.out.println(p.exitValue()); > } > catch(Exception e) { > System.out.println(e); > } > } > }
Replies:
|