Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

Java Compiler

$
0
0
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 :
vb.net Code:
  1. Dim myprocess As New Process
  2.         Dim runpath As String
  3.         Dim path As String
  4.         path = "javac " + TextBox1.Text + ".java"
  5.         runpath = "java " + TextBox1.Text
  6.         Dim StartInfo As New System.Diagnostics.ProcessStartInfo
  7.         StartInfo.FileName = "cmd" 'starts cmd window
  8.         StartInfo.RedirectStandardInput = True
  9.         StartInfo.RedirectStandardOutput = True
  10.         StartInfo.RedirectStandardError = True
  11.         StartInfo.UseShellExecute = False 'required to redirect
  12.         StartInfo.CreateNoWindow = True
  13.         myprocess.StartInfo = StartInfo
  14.         myprocess.Start()
  15.  
  16.         Dim SR As System.IO.StreamReader = myprocess.StandardOutput
  17.         Dim SW As System.IO.StreamWriter = myprocess.StandardInput
  18.         SW.WriteLine("set path=C:\Program Files\Java\jdk1.7.0\bin") 'the command you wish to run.....
  19.         SW.WriteLine("cd C:\Users\abcd\Desktop\Cloudproject\javacodes") 'the command you wish to run.....
  20.  
  21.         SW.WriteLine(path) 'the command you wish to run.....
  22.  
  23.         SW.WriteLine(runpath)
  24.        
  25.         SW.WriteLine("exit")
  26.        RichTextBox2.Text= SR.ReadToEnd 'returns results of the command window
  27.         SW.Close()
  28.         SR.Close()
  29.     End Sub

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>