pyimagej
pyimagej copied to clipboard
Plugins in the plugin folder cannot be used if they are just .class files.
Some plugins are used by just putting a class file in the plugins folder. These plugins do not load properly in pyimagej.
To reproduce this, take an example plugin and compile it to a class file and place it in the fiji plugins folder.
import ij.plugin.PlugIn;
public class Example_Plugin implements PlugIn {
@Override
public void run(String s) {
System.out.println("That's the one");
}
}
Starting fiji, the Example Plugin will be available in the menu and running it should produce the desired output.
Starting pyimagej.
import imagej
ij = imagej.init("Fiji.app", mode='interactive')
ij.ui().showUI()
Note the "Fiji.app" is the path to the Fiji that has the plugin installed. This should display the UI with Example Plugin in the menu. Trying to run it will cause a class not found exception.
One work around is the put the class file into a jar.
jar cf Example_Plugin.jar Example_Plugin.class
Restarting pyimagej the plugin should work fine.
This issue has been mentioned on Image.sc Forum. There might be relevant details there:
https://forum.image.sc/t/issue-with-loading-local-plugins-with-pyimagej/100279/9
This issue has been mentioned on Image.sc Forum. There might be relevant details there:
https://forum.image.sc/t/adjustable-watershed-plugin-in-pyimagej/100563/3
See also this Zulip topic, where I describe some findings related to this issue.
This issue has been mentioned on Image.sc Forum. There might be relevant details there:
https://forum.image.sc/t/fiji-latest-java-21-bundles-ready-for-community-testing/112417/57
I opened https://github.com/imagej/pyimagej/issues/334 which I then closed as duplicate of this issue, but wanted to mention that I did find a particular line (addLegacy = false) which when I removed, allowed me to load .class plugins. But I wanted to look more into this flag to find what the proper fix is
When I specify an imagej installation I can get .class files to load if I include a jars.append( ij_dir + "/plugins") Then plugins gets added to the classpath and .class files get loaded. This is similar to the jaunch solution where a folder needs to be added to the fiji.toml.
I added the line here https://github.com/imagej/pyimagej/blob/74d7d2210201d3523d208a2b5793e08e0a92c4aa/src/imagej/init.py#L1675