1

In a custom ImageJ plugin, before IJ.run(imp, myCommand, myArguments) I would like to check if myCommand exists and if not - try another command.

There doesn't seem to be a method for this purpose in the IJ class. What are the alternatives to try {} catch?

alephreish
  • 490
  • 3
  • 15

1 Answers1

2

Some alternatives:

  1. Write an ImageJ2 plugin so your command will be automatically exposed in the framework, e.g. in the CommandService. This would also allow you to use prioritization of plugins, which it sounds is potentially what you're looking for.

  2. You could use Menus.getCommands(): if (Menus.getCommands().get(command) != null) IJ.run(command);

  3. Try...catch a Class.forName call

Community
  • 1
  • 1
hineroptera
  • 769
  • 3
  • 10