Advertisement
|
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:
Runtime.getRuntime().exec
Posted by sasi on April 26, 2000 at 6:26 PM
Hi, I was trying to run a batch file from my program, so I did the following: public static void main (String []args) { /* Threadtest t = new Threadtest(); t.start();*/ testrun(); } public static void testrun () { BufferedReader br = null; BufferedReader br2 = null; Process p = null; int status = -1; try { String osName = System.getProperty("os.name"); if (osName.compareTo("Windows NT") == 0) { //String []test = "cmd.exe", "/c", "runtest.bat"); p = Runtime.getRuntime().exec("cmd.exe /c runtest.bat "); } br = new BufferedReader(new InputStreamReader(p.getErrorStream())); String s; while ((s = br.readLine())!= null) { System.out.println(s); } br2 = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((s = br2.readLine())!= null) { System.out.println(s); } br.close(); br2.close(); }catch (IOException ioex) {ioex.printStackTrace();} //return 0; } Now, this starts the dos prompt, and then the program waits on it. It only continues after I kill the dos prompt. Is there any way that I can start the process and then forget about it? I dont want to have any control after spawning off the process. Could anyone help me with this problem? Thanks Sasipriya
Replies:
- using runtime.exec in a jsp Doug February 20, 2002 at 4:50 PM
(0)
- Try this Amit August 27, 2001 at 1:51 PM
(0)
- Same problem with JSP Ritu S Parihar May 02, 2001 at 7:12 AM
(2)
- ur answer Manoj September 06, 2001 at 4:21 AM
(0)
- ur answer Manoj September 06, 2001 at 4:20 AM
(0)
- Same problem with JSP Ritu S Parihar May 02, 2001 at 7:11 AM
(0)
- Same problem with JSP Ritu S Parihar May 02, 2001 at 7:10 AM
(0)
- Same problem with JSP Ritu S Parihar May 02, 2001 at 7:09 AM
(0)
- use byte buffer instead of char buffer Nathan Cho January 12, 2001 at 8:58 PM
(1)
- Runtime exec Hien Tran June 12, 2000 at 2:23 PM
(13)
|