users@jaxb.java.net

Re: Capturing xjc error messages

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 03 Jan 2005 17:21:29 -0800

Siddharth Patil wrote:
> I'm using the xjc compiler from my program, and would like to capture the
> warning/error messages and display them within my GUI. Raw output redirected
> to my program is enough. Any tips on how to do this would be greatly
> appreciated.

If you are capturing the raw output, then there's really nothing XJC
specific about this, is there.

If you are launching it as a separate process you can capture
stdout/stderr. If you are launching it in the same VM, you can call the
following com.sun.tools.xjc.Driver.main method;

> /**
> * Performs schema compilation and prints the status/error into the
> * specified PrintStream.
> *
> * <p>
> * This method could be used to trigger XJC from other tools,
> * such as Ant or IDE.
> *
> * @param args
> * specified command line parameters. If there is an error
> * in the parameters, {_at_link BadCommandLineException} will
> * be thrown.
> * @param status
> * Status report of the compilation will be sent to this object.
> * Useful to update users so that they will know something is happening.
> * Only ignorable messages should be sent to this stream.
> *
> * This parameter can be null to suppress messages.
> *
> * @param out
> * Various non-ignorable output (error messages, etc)
> * will go to this stream.
> *
> * @return
> * If the compiler runs successfully, this method returns 0.
> * All non-zero values indicate an error. The error message
> * will be sent to the specified PrintStream.
> */
> public static int run(String[] args, PrintStream status, PrintStream out)



-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net