I'm writing a program in C# that will compile java files using the java compiler (javac). I am having trouble capturing the output from javac (a command-line tool) to tell the user of errors. I know how to start a process and capture the standard output, but javac returns nothing. Is there any other way that I can capture the output, or better yet, get a list of errors from java compiler?
+1
A:
I think this is happening because errors are being sent to stderr
instead of stdout
. One way you can get around this is to redirect output to stderr
to stdout
and capture that. eg:
javac files.java 2>&1
Or you can also access the Process.StandardError
stream as MAKKAM suggested.
NullUserException
2010-09-23 04:41:15
+2
A:
May be you better use error output of the process. Process.StandardError
MAKKAM
2010-09-23 04:44:03
Thank you... I had StandardError set up, but I forgot to redirect the standard error.
Nolan
2010-09-23 04:54:07