Login  Register

Re: Using System.out and System.err from ImageJ plugins (Java)

Posted by dscho on Feb 27, 2013; 8:29pm
URL: http://imagej.273.s1.nabble.com/Using-System-out-and-System-err-from-ImageJ-plugins-Java-tp5001799p5001902.html

Hi,

On Wed, 27 Feb 2013, Rasband, Wayne (NIH/NIMH) [E] wrote:

> On Feb 18, 2013, at 7:46 AM, Burger Wilhelm wrote:
>
> > I would like to share a piece of Java code for ImageJ that I wrote out
> > of need and perhaps others might find useful too:
> >
> > This small library facilitates the redirection of output to System.out
> > and System.err to the ImageJ Log-console. Typically in ImageJ output
> > sent to the standard system streams by calls such as
> > System.out.println(...) are suppressed. Redirecting the standard
> > output streams makes this output appear in ImageJ's log console,
> > analogous to using the IJ.log() method. This is particularly useful
> > for debugging imported code and for writing classes that are
> > independent of ImageJ.
> >
> > More details and the complete code with examples can be found here:
> > http://staff.fh-hagenberg.at/burger/imagej/index.html
> >
> > Comments and suggestions for improvements are welcome.
>
> This library is built into the ImageJ 1.47m daily build as the
> ij.io.LogStream class. You can redirect System.out and System.err
> messages to the Log window by enabling debug mode in Edit>Options>Misc.

I am glad you liked my approach, but I would have preferred it if my code
had just been reused... it was unnecessary to reinvent the wheel.

In any case, this interferes with Fiji's stdout/stderr handling. I am
fixing it as we speak.

Note also that the non-standard naming and location of the scripting
languages' .jar files are incompatible with Fiji's well-established
conventions. It would have been nice to avoid that.

Likewise, we, too, hardcoded languages into Fiji's scripting core. There
was a lesson in that, and we learnt from it: ImageJ2's scripting core is
completely independent of language-specific .jar files. I would strongly
suggest to learn that lesson from Fiji and not repeat the mistake in
ImageJ1.

Ciao,
Johannes

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html