Problem modifying and implementing an existing plugin

I am attempting to work around a problem I encountered using the wrmtrck plugin.
I want to implement the wrmtrck plugin from the command line using a macro file with “–headless” enabled. However, I repeatedly get an error that starts with:

java.awt.HeadlessException
  at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
  at java.awt.Window.<init>(Window.java:536)
  at java.awt.Frame.<init>(Frame.java:420)

It seems this error is caused when the wrmtrck plugin asks for input from the GUI and the GUI is not open. I thought I could go in and modify wrmtrck so that it doesn’t ask for input from the GUI, but I am having trouble figuring out how to do that. All that’s provided in the wrMTrck source code on github (https://github.com/jespersp/wrMTrck) is a file called wrMTrck_.java

How can I modify this file and install it as a plugin for Fiji?

Hello Andrew -

I can’t speak to how to change the wrMTrck_ plugin so that it
will run in headless mode. I’ve never used headless mode, and
I don’t know enough about wrMTrck_ to know whether it uses
the gui in an essential way.

However, modifying wrMTrck_ and installing it as a plugin is easy.

First, the wrMTrck_ plugin lives in a single .java file. Furthermore
the class wrMTrck_ is in java’s “default” package – that is, there
is no package statement in wrMTrck_.java. This makes setting
things up very simple.

I copied wrMTrck_.java from the github link you posted, compiled
it, and copied the resulting wrMTrck_.class file to Fiji / ImageJ’s
plugins directory. (That’s the “installation” step.) Relaunching
Fiji causes Fiji to recognize it as a plugin, and add the
Plugins > wrMTrck command to its menu bar. I can then run
Plugins > wrMTrck. (It launches, so I’ll assume that it works,
but I don’t really know what it is supposed to do.)

I find the easiest way to compile things like this is just to run javac.

Make sure you have javac (from the java sdk) – not just java –
installed on your system, and point your java classpath to your
Fiji jars directory.

In my case I run

javac -source 1.8 -target 1.8 -g -cp .:/<path_to_fiji_install>/Fiji.app/jars/* wrMTrck_.java

(The -source and -target flags are because the java version I
use to compile is 1.9, but my copy of Fiji / ImageJ is java 1.8.)

I then copy the resulting wrMTrck_class to

/<path_to_fiji_install>/Fiji.app/plugins

launch Fiji, and run the plugin.

To modify wrMTrck_ you edit wrMTrck_.java, recompile, copy to
the plugins directory, and relaunch Fiji. I would suggest that you
see if you can get this far, and then try making some trivial but
visible modification, and see if you can actually run your modified
version.

(Again, how to make it compatible with headless mode I don’t know.)

Thanks, mm