Login  Register

Re: How to test plugin?

Posted by dscho on Jul 14, 2009; 10:42am
URL: http://imagej.273.s1.nabble.com/How-to-uninstall-macros-tp3691772p3691775.html

Hi Vivian,

On Tue, 14 Jul 2009, Vivian Yong wrote:

> I tried to write a testing plugin based on the ImageJ tutorial. I can
> test it after I put the plugin file in the ImageJ plugin folder. I just
> wonder how can I test run it in Eclipse? Also, I would like to see the
> output on the system for debugging purpose by using
> System.out.print("..."); before the plugin be deployed to ImageJ, is
> that possible and how?

In a plugin I recently reviewed, I saw this gem:

        public static void main(String[] args) {
                try {
                        System.getProperties().list(System.err);
               System.setProperty("plugins.dir", args[0]);
                        new ImageJ();
                        IJ.run("This Plugin", "argument=value argument=value");
                } catch (Exception ex) {
                        e.printStackTrace();
        }
        }

You specify the plugin class as main class, and pass the main() method the
path to the directory containing the corresponding .class file.  Before
constructing ImageJ(), you can output anything to System.out (or
System.err).  Of course, you need to adjust the parameters of IJ.run()
appropriately.

Hth,
Dscho