Hello,
I haven't really used ImageJ from the command prompt before, if I want to pass 4 String variables in my Gamma4 class run method is it a simple case of putting: public void run(String[] args) { double X1,X2,Y1,Y2; if (args.length>0) try{ X1 = Double.parseDouble(args[0]); X2 = Double.parseDouble(args[1]); Y1 = Double.parseDouble(args[2]); Y2 = Double.parseDouble(args[3]); } Only every time I try to "Compile & Run" my program I have the following error message, /home/gary/.imagej/plugins/Gamma4.java:13: error: Gamma4 is not abstract and does not override abstract method run(String) in PlugIn public class Gamma4 implements PlugIn { ^ 1 error 1 warning Any ideas what I have done wrong? Thank you in advance |
Hello,
the error is there because you do not implement the method run of the interface PlugIn. Your method run has a different signature. It has String[] as argument instead of the String in PlugIn. You should write your plugin normally and use a GenericDialog for the parameters. You can then call it from the commandline with something like this: ImageJ -eval "run('Plug In', 'arguments');" -batch Volker On 05/17/2013 01:24 PM, bateman wrote: > Hello, > > I haven't really used ImageJ from the command prompt before, if I want to > pass 4 String variables in my Gamma4 class run method is it a simple case of > putting: > > public void run(String[] args) > { > double X1,X2,Y1,Y2; > if (args.length>0) > try{ > X1 = Double.parseDouble(args[0]); > X2 = Double.parseDouble(args[1]); > Y1 = Double.parseDouble(args[2]); > Y2 = Double.parseDouble(args[3]); > } > > Only every time I try to "Compile & Run" my program I have the following > error message, > > /home/gary/.imagej/plugins/Gamma4.java:13: error: Gamma4 is not abstract and > does not override abstract method run(String) in PlugIn > public class Gamma4 implements PlugIn { > ^ > 1 error > 1 warning > > Any ideas what I have done wrong? > > Thank you in advance > > > > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/Using-imageJ-from-the-command-line-in-Ubuntu-tp5003041.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
So I cannot specify more than one string object in my "run" command? Is that the case?
|
>So I cannot specify more than one string object in my "run" command? Is that >the case? Yes, but you can still parse the one string object yourself, using something like String[] args = originalArgString.split(" "), then the rest of your code can be left as is. -Justin -- View this message in context: http://imagej.1557.x6.nabble.com/Using-imageJ-from-the-command-line-in-Ubuntu-tp5003041p5003043.html Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by bateman
On 17.05.2013 14:52, bateman wrote:
> So I cannot specify more than one string object in my "run" command? Is that > the case? Right, but that does not mean that you cannot pass more than one parameter: it just means you have to specify the parameters in a way that GenericDialog will understand, that is using the field labels as variable names. Here is an example from a recent post ( http://permalink.gmane.org/gmane.comp.java.imagej/28605 ): | int sizeE = 2; | IJ.run(imp2, "Gray Morphology", | "radius="+sizeE+" type=circle operator=erode"); (this is from within Java code, strip "IJ." etc for the command line / macro version) (and in case you want to pass strings, you have to bracket them using []) HTH Adrian -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |