Getting console output from jar in c#
i have a jar which if i run from th开发者_运维问答e command line returns me a true or false printed to the console
i am trying to run this from c# and obtain the result - this is being done like this
Process p = new Process();
p.StartInfo = new ProcessStartInfo("java", @"-jar test.jar " + paramterForStringArgs[0]);
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();
String s = p.StandardOutput.ReadToEnd();
p.WaitForExit();
Trace.WriteLine("data = " + s);
return false;
I seem to be always getting an empty string and was wondering why this might be, or if there was a better way of doing it?
Setting RedirectStandardError
and calling p.StandardError.ReadToEnd()
reads any error output from the process.
精彩评论