-
May 19th, 2009, 11:08 AM
#1
Calling JAR file hangs Process
.NET version: 2.0
Platform: Windows XP, SP2
Compiler: VS2005
Problem:
I call a JAR file using a Process by first passing in a ProcessInfo object. The JAR file runs successfully, however, the java.exe process does not terminate even when consuming ~0 CPU cycles. Hence a call to Process::waitForExit() hangs my program. Anyone run into this sort of problem?
Code:
Code:
ProcessStartInfo AcSPInfo = new ProcessStartInfo("\"C:\\Program Files\\Java\\jre1.6.0_07\\bin\\java.exe\"",
" -jar C:\\Workspace\\Scratch\\AcSP.jar");
AcSPInfo.WorkingDirectory = "C:\\Workspace\\Scratch";
AcSPInfo.RedirectStandardError = false;
AcSPInfo.RedirectStandardInput = false;
AcSPInfo.RedirectStandardOutput = true;
AcSPInfo.CreateNoWindow = true;
AcSPInfo.UseShellExecute = false;
Process AcSP = new Process();
AcSP.StartInfo = AcSPInfo;
try
{
AcSP.Start();
StreamReader output = AcSP.StandardOutput;
AcSP.WaitForExit(); //la la la, when will you finish!?
Console.Out.Write(output.ReadToEnd());
}
catch (Exception e)
{
Console.Out.WriteLine(e.Message);
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|