I am Developing an application for my project in which i'm providing the users to enter their java code in a richtextbox & when user clicks on the run button I am showing the output of the programme in another richtextbox.But The problem is that i'm able to do so only for static programmes but not for the user intertactive programmes
wherein the user is asked to provide some input My code is :
wherein the user is asked to provide some input My code is :
vb.net Code:
Dim myprocess As New Process Dim runpath As String Dim path As String path = "javac " + TextBox1.Text + ".java" runpath = "java " + TextBox1.Text Dim StartInfo As New System.Diagnostics.ProcessStartInfo StartInfo.FileName = "cmd" 'starts cmd window StartInfo.RedirectStandardInput = True StartInfo.RedirectStandardOutput = True StartInfo.RedirectStandardError = True StartInfo.UseShellExecute = False 'required to redirect StartInfo.CreateNoWindow = True myprocess.StartInfo = StartInfo myprocess.Start() Dim SR As System.IO.StreamReader = myprocess.StandardOutput Dim SW As System.IO.StreamWriter = myprocess.StandardInput SW.WriteLine("set path=C:\Program Files\Java\jdk1.7.0\bin") 'the command you wish to run..... SW.WriteLine("cd C:\Users\abcd\Desktop\Cloudproject\javacodes") 'the command you wish to run..... SW.WriteLine(path) 'the command you wish to run..... SW.WriteLine(runpath) SW.WriteLine("exit") RichTextBox2.Text= SR.ReadToEnd 'returns results of the command window SW.Close() SR.Close() End Sub