Why the Compile and Run command doesnt work in Fiji?

I am an ImageJ plugin developer and I am trying to move to Fiji, so i have some questions:

  1. In ImageJ there is a Compile and Run command that creates the precompiled .class file which saves compilation time for posterior calls, that function in fiji just says that it is not supported. Surely there is a workaround for this, but is not clear for me. Can somebody points me in the right direction?

  2. even if I have a .class file in the plugins folder (compiled with ImageJ), Fiji insist in compiling the .java file. Is this an intended behaviour? How can I change to use the .class file? Why should I create a .jar package in development stage?

Lets just start with these two questions for now.
Happy imaging
BW

This functionality is not supported, being one of the cases where behavior from ImageJ 1.x was not preserved in ImageJ2 (and thus Fiji). Java is a compiled language, and attempting to behave otherwise lead to a custom compiler, class loader issues, and a generally unreasonable maintenance burden.

If you want to write plugins where you can change code within ImageJ and see the results without relaunching, I suggest writing in one of the non-Java scripting languages. If you want to write in Java, I believe the benefits of using an IDE outweigh the need to restart ImageJ.

Making a .jar allows you to bundle your classes with relevant metadata, allowing you to provide one unified artifact that can be versioned, store plugin information, and other resources (e.g. example scripts). If your plugin is built with Maven (whether on the command line or through an IDE) you have a consistent workflow for installing your .jar and dependencies to an ImageJ installation… so in my mind the only reason not to build a .jar is if you don’t want to use these development tools. But in that case, I would recommend scripts again.

Hope this helps. Please let me know if you have any questions about these, or other, topics.

2 Likes

That was very helpful. I am using Netbeans 8.1 in windows 8 x64 and I have already write a set of java classes that worked in ImageJ 1.x, what I want is to port them to Fiji. I write the plugins.config with the required things, also I figured out a pom.xml, but not sure if it is ok since maven requires a specific folder structure (/src/main/java, /src/main/resources) wich by now destroys the intrinsic dependencies in my project, is there a guide on how to do this? All I find is helpless. the resulting jar file is not being saw by Fiji. However the folder with the .class files is working already there. But I see this is not the standard way.

Yes, the minimal-ij1-plugin project was designed to model exactly this, and includes a README describing the intended steps for adapting an ImageJ 1.x plugin to a standard Maven structure. It does require restructuring your files, but ideally your dependencies will turn into Maven dependencies.

I suggest taking a look at that project and if any of the instructions are unclear (or don’t work properly) let us know here and we can help (and hopefully improve the instructions for others).

Also, if you can share your project on GitHub (or equivalent) I can give more specific advice.

1 Like

let me know your github user name to share the project, or let me know if you can see it in https://github.com/BishopWolf/NMQC

When I use the folder format given in https://github.com/imagej/minimal-ij1-plugin/ I can create a .jar but

  1. Netbeans complains about the package (Warning wrong package) as it is located in a folder with a different name
  2. The resulting .jar does not contain plugins.config in the root, but it remains inside /src/main/resources.

I just wonder how to configure Netbeans so it creates a proper .jar

Yep, your repository is not private so I’m able to see it. I’ll take a look…

This sounds like your Netbeans may not be recognizing your project as a Maven project, as it should not see the src/main/java as package prefixes, and everything in src/main/resources should be placed at the top level of the resulting jar.

After converting to the maven file structure on disk you might try closing and re-importing to Netbeans.

If that doesn’t help, you can try running mvn clean package from the command line in the same directory as your pom.xml and check the structure of the output .jar (in /target/). That will tell you if it’s a problem with your Maven configuration, or Netbeans.

@BishopWolf Ah, it looks like your artifactId was missung an underscore (’_’) so ImageJ wasn’t finding your plugins. The individual classes work because all of your class names contain underscores.

With these changes I was able to build your plugin with maven and have it working when dropped into a Fiji installation.

1 Like

Another possibility instead of renaming the artefact would be to add a <finalName>myJar_</finalName> tag inside the <configure> of the maven-jar-plugin section.

Regards,
Richard

1 Like

I have made all your changes and it works like a charm, thank you very much! I can create my own Fiji plugins now!

2 Likes

If you may try to clone my project again, you might find it useful if you use a scintillation camera.

Download “imajej”. In “fiji imagej” doesn’t work. Then => compile and run (after that a accept download the aplication) => restart the program and now the ELA analysis is under Plugins tab.

ImageJ link:

https://imagej.nih.gov/ij/download.html
ELA link:
http://svg.dmi.unict.it/iplab/imagej/Plugins/Forensics/ErrorLevelAnalysis/ErrorLevelAnalysis/ErrorLevelAnalysis.html

@Sebast I’m sorry, but I don’t understand your post? Is something not working for you?

No. The pluggin doesn’t work in “fiji imagej” but It does in “imageJ”.

I came to this post looking how to make this plugin work. I found that I can compile in “imagej” but not in “fiji imagej”.
I guess someone else can have this problem and will find this post when searching for the answer so I put the easy way to solve It.

I understand that is not the main subject of the post but someone who is only interested in using this plugin regardless of whether he is using “imagej” or “fiji imagej” can find useful this information.

Sorry for my English, I hope you understand what I wrote