imagej / pyimagej

Use ImageJ from Python
https://pyimagej.readthedocs.io/
Other
467 stars 81 forks source link

Plugins in the plugin folder cannot be used if they are just .class files. #313

Open odinsbane opened 3 weeks ago

odinsbane commented 3 weeks ago

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.

odinsbane commented 3 weeks ago

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.

imagesc-bot commented 3 weeks ago

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

imagesc-bot commented 3 weeks ago

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

ctrueden commented 3 weeks ago

See also this Zulip topic, where I describe some findings related to this issue.