You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Martin Burger <m...@rtin-burger.de> on 2005/09/14 08:54:59 UTC
Redirect output of Javac task
Hello!
I'm using the Javac task to compile Java sources programmatically. If
there is an compile error, the Javac tasks (more specific the
com.sun.tools.javac.Main compiler) prints it's error to the console
(System.err).
Currently, I'm setting System.err to a new PrintStream just before I
call Javac.execute(). After that call, I restore the old stream. I think
this solution is not perfect, at least it is not thread safe. But I
found no other solution. Does anybody know a better way to bar the
compiler from printing to the console?
Thanks,
Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Redirect output of Javac task
Posted by Steve Loughran <st...@apache.org>.
Martin Burger wrote:
> Hello!
>
> I'm using the Javac task to compile Java sources programmatically. If
> there is an compile error, the Javac tasks (more specific the
> com.sun.tools.javac.Main compiler) prints it's error to the console
> (System.err).
>
> Currently, I'm setting System.err to a new PrintStream just before I
> call Javac.execute(). After that call, I restore the old stream. I think
> this solution is not perfect, at least it is not thread safe. But I
> found no other solution. Does anybody know a better way to bar the
> compiler from printing to the console?
>
no, that is how sun do it, and until the JCP for a proper programmatic
API for compiling is implemented, it is all you get.
you could do a fancy PrintStream that splits stuff up based on thread
underneath...
-steve
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org