execute String as code in ImageJ(java)

Tag: imagej Author: wendyww001 Date: 2010-08-11

The code is in the String, example:

String str = "IJ.run(\"FJ Edges\", \"\");";

If str is executed, the corresponding contents will run.

Glad to hear it. Sounds like your problem is already solved.
possible duplicate: also: ...and:
can you you provide the exact example. Im not familiar with these scripting technique and is it executable in ImageJ platform...?

Other Answer1

It's not quite clear to me what you want to do, but in the example you give there's no reason not to call IJ.run() directly - for example, in a plugin this would be:

import ij.plugin.PlugIn;
import ij.IJ;

public class Simple_PlugIn implements PlugIn {
    public void run(String arg) {
        IJ.run("FJ Edges","");
    }
}

If you really do want to evaluate arbitrary Java code from a String, then the links Matt Ball suggested in his comments will help.

If you just want to do simple scripting in ImageJ, though, it will be easier to use the macro language or Javascript. You can find a guide to the former here:

http://rsbweb.nih.gov/ij/developer/macro/macros.html

(In most cases it's helpful to start your script by using the macro recorder (in Plugins > Macros > Record...)) I hope that's of some use.