In the last practical, we've seen how to create a Fiji plugin which is runnable on IntelliJ.
In this practical, we'll see how to export the plugin to a .jar file and to make it run in any Fiji app.
Building a plugin simply means creating a .jar file of the project. This jar contains the compiled code (i.e. bytecode with .class extension) of your project. This packaging can be read by any computer with a decent Java installation
To generate the .jar file
- Go under
maven -> intelliJ-workshop -> Lifecycleand double-click oninstallThis will launch the compiler.
- Once the compilation phase in done, a target folder is created in the project folder.
This folder contains bytecodes and the plugin.jar. To open the location of this
folder, you can do a
right click -> Open in -> Explorer/Finder.
Note: In the target folder, you'll find two .jar file.
- plugin.jar
- plugin-sources.jar
We are only interested in plugin.jar
Have a look to the name of the .jar file
intellij-workshop: the first part corresponds to theartifactIdyou've set in the pom.xml1.0.0: this second part corresponds to the version number declared in the pom.xml
Now the plugin is built, we need to add it in Fiji to be able to use it.
- Browse your
Fiji.appfolder
On Windows, you should have installed it under
C:/Fiji.app.On Mac, you should have installed it under the
Applicationfolder. Right-click on the Fiji logo and click onShow package content.
- Drag-drop the plugin.jar file inside the
Pluginsfolder of Fiji. - Start or restart Fiji.
- Open the
blobimage - Go under
Plugin -> IntelliJ_Workshop -> FloodFillerand run the plugin
An error message appears, telling you that the Label2ROIs class cannot be found.
What can be the cause of this issue ?
This is because the Fiji you are using doesn't include the LaRoMe dependency we've added to the code. Fiji doesn't interact with IntelliJ.
In order to solve this issue, we need to add this dependency in Fiji as well.
- Find the online GitHub repository of the dependency
- Follow installation instructions.
- Restart Fiji
- Test again the plugin ; it should work.
Note: When you are developing some new code, it is very important to pay attention to what dependencies you are using. Are those dependencies available online ? Are they versioned ? Where can we find them ? Are they maintained over time ? Are they compatible with the tool I'm using/the app which will host it ?... All those questions should be addressed if you would like to have a stable and long-term tool.