I'm having an issue with the following code:
private void Form1_Load(object sender, EventArgs e)
{
cmdOutput = new StringBuilder("");
cmdProcess = new Process();
cmdProcess.StartInfo.WorkingDirectory = @"C:\android-sdk\tools";
cmdProcess.StartInfo.FileName = @"java";
cmdProcess.StartInfo.Arguments = @"-Xmx512m -Djava.ext.dirs=lib\;lib\x86_64 -Dcom.android.monkeyrunner.bindir=..\framework -jar lib\monkeyrunner.jar";
cmdProcess.StartInfo.UseShellExecute = false;
cmdProcess.StartInfo.CreateNoWindow = true;
cmdProcess.StartInfo.RedirectStandardOutput = true;
cmdProcess.OutputDataReceived += new DataReceivedEventHandler(SortOutputHandler);
cmdProcess.StartInfo.RedirectStandardInput = true;
cmdProcess.Start();
cmdStreamWriter = cmdProcess.StandardInput;
cmdProcess.BeginOutputReadLine();
// Even if i fire this later it doesn't work.
cmdStreamWriter.WriteLine(@"print 'Hello World'");
}
The issue is that:
cmdStreamWriter.WriteLine(@"print 'Hello World'");
Is not doing anything. Nothing is being written to the java process.
The output appears to be working fine (tested by loading a script directly to monkeyrunner.jar. But after trying many times I'm not getting any input.
This does work fine if I change the process to "cmd"