Example for a simple IJ2 / Fiji Plugin

Wonder how to write a IJ2 / Fiji Plugin (Command) that can run nicely from within Eclipse and Fiji or ImageJ2?

There are several answer Google gives you, and most of them go the old IJ (1) way. If you want to use ops or any of the IJ2 services you will appreciate this:

https://github.com/imagej/imagej-tutorials/blob/9baa3bffded39736c0e41cb46ddba7dc15f88260/simple-commands/src/main/java/OpenImage.java#L92-L105

Or this one (which also uses ops to work on images):

https://github.com/imagej/imagej-tutorials/blob/master/simple-commands/src/main/java/OpenScaleSaveImage.java

Using maven to deploy directly to a Fiji installation

This is extremely useful just before you want to upload your plugin(s) to your/a update site. If this really is you use case, you might want to check that the parent POM version you are using coincides with the one of the latest Fiji release!

The command for this is:

mvn -Dimagej.app.directory=/Applications/Fiji.app/ -Ddelete.other.versions=true clean install

And in case the enforcer annoys you — it can be turned off like this:

mvn -Dimagej.app.directory=/Applications/Fiji.app/ -Ddelete.other.versions=true -Denforcer.skip=true clean install

Enjoy,
Florian

Change the Fiji temp Folder (by passing JVM arguments)

Why? For example if you run Fiji headless on a cluster and you would like it to use a fast local folder instead of a network drive.

This page tells you how you can pass on JVM arguments to Fiji upon start: http://fiji.sc/Java_Options

One can specify the “temp” directory using the following command:

$ fiji -Djava.io.tmpdir=~/tmp -- &

Double dash at the end is required to specify that the given argument is for Java.

Find JAR Containing Specific Class

Tons of JARs are in the classpath of Fiji. Multiple JARs might contain the same class definition.

In order to know which JAR is the one hosting the version Fiji is actually using (this is determined by the order those JARs are found in the CLASSPATH), you can use this handy function from within Fiji.

Start Fiji – hit ctrl+L or cmd+L on your keyboard – type ‘jar’ in the search field – start ‘Find jar for class’ and type the name of the class + the entire package information as shown below – hit ‘Ok’ – done!

Fiji_findJarForClass