Process Not Getting EXITED
BATCH FILE
LOCATION : D:\test.bat
Ex: test.bat It contains
del c:\sample.txt
JAVA FILE
LOCATION : c:\testunion.java
import java.util.*;
import java.io.*;
public class testunion
{
public static void main(String args[])
{
try
{
Runtime objRt = null;
Process objProc = null;
objRt = Runtime.getRuntime();
String szIntfFile = "D:\\test.bat";
objProc = objRt.exec(szIntfFile);
}
}
}
ENVIRONMENT : WINDOWS 2k
When testunion.java file is RUN, test.bat is called and sample.txt gets deleted.
BUT THE CONTROL IS NOT COMING OUT FROM THE COMMAND PROMPT.THE CURSOR STAYS IN THE
COMMAND PROMPT BLINKING.
I think the sub Process is not getting EXITED.....
I want the subprocess to execute and get exited. so that the Main Process does not hang...
How to do it ?
[972 byte] By [
PrabhuSai] at [2007-9-30 14:32:52]

Even though the docs say the methods of Process are abstract you can use them because you are really using java.lang.ProcessImpl
I believe you need to provide a sink for the process's InputStream to your testunion(better practice TestUnion)
try
{
Runtime objRt = null;
Process objProc = null;
objRt = Runtime.getRuntime();
String szIntfFile = "c:\\jar MathML-X.cmd";
objProc = objRt.exec(szIntfFile);
java.io.InputStream is=objProc.getInputStream();
int value=0;
StringBuffer sb=new StringBuffer();
while((value=is.read())!=-1)
{
if(value==10)
{
System.out.println(sb.toString());
sb.setLength(0);
}
else
{
sb.append((char)value);
}
}
objProc.waitFor();
}
catch(java.io.IOException ioe)
{
System.out.println("ioe: "+ioe.getMessage());
}
catch(java.lang.InterruptedException ie)
{
System.out.println("ie: "+ie.getMessage());
}