System process to capture java application

Jun 9 2012 2:48 AM
hello, i have a problem im creating an application that runs a java.class code using the system process a can actually compile and run the code using javac.exe and java.exe the problem is that i have a code that ask the user for an input, the message actually shows in the textbox using the redirectstardardoutput but then it crashes when ask for the input. heres the code. thanks

private void LaunchProcess(string class)
        {
            string app = varGlob.JAVADIR + "java.exe ";
            string ex1 = "\"" + class+ "\"";

            
            build.StartInfo.WorkingDirectory = varGlob.JAVADIR;
            build.StartInfo.Arguments = ex1;
            build.StartInfo.FileName = app;

            build.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            build.StartInfo.UseShellExecute = false;
            build.StartInfo.RedirectStandardOutput = true;
            build.StartInfo.RedirectStandardInput = true;
            build.StartInfo.RedirectStandardError = true;
            build.StartInfo.CreateNoWindow = false;
            
            build.ErrorDataReceived += build_ErrorDataReceived;
            build.OutputDataReceived += build_ErrorDataReceived;
            
            build.EnableRaisingEvents = true;
            //build.Exited += build_Exited;
            build.Start();
            build.BeginOutputReadLine();
            build.BeginErrorReadLine();
            
//          build.StandardInput.WriteLine("5");
            build.WaitForExit();
            cmp.TME.error(str, 0);
            cmp.TME.error("", 0);
            cmp.TME.error("output generated.", 0);

        }
       
        void build_ErrorDataReceived(object sender, DataReceivedEventArgs e)
        {
            string strMessage = e.Data;

            str += strMessage;

        }