Hi All
I'm having trouble getting tidy menu items for my plugins. I followed the IJ-Eclipse best practice instructions from the IJ conference in Luxembourg and started putting my plugins in packages, e.g. in Fit_Sphere.java package org.doube.bone_geometry; But then I get lots of levels of menus before I can select a plugin, which is a pain, e.g.: Plugins>org>doube>bone_geometry>Fit Sphere So I wrote a plugins.config file, using these instructions: https://list.nih.gov/cgi-bin/wa?A2=ind0804&L=IMAGEJ&P=R5626&I=-3 http://imagejdocu.tudor.lu/doku.php?id=howto:plugins:howto_create_an_imagej_plugin_jar_file But if I put this in my plugins.config: Plugins>Bone Geometry, "Fit Sphere", org.doube.bone_geometry.Fit_Sphere("") I get the menu entry Plugins>Bone Geometry>Fit Sphere, but running it throws this exception: Plugin or class not found: "org.doube.bone_geometry.Fit_Sphere (java.lang.ClassNotFoundException: org.doube.bone_geometry.Fit_Sphere) Bone_Geometry.jar is saved in ~/ImageJ/plugins/ and plugins.config is in the root directory of the jar, and all the class files are in /org/doube/bone_geometry/ within the jar. How can I fix this? Cheers Mike |
When I package things, I put my jars that are equivalent to your
"Bone_Geometry.jar" in the directory ~/ImageJ/plugins/jars, and as you said, I put the plugins.config in the root directory of said jar file. Hope that helps/works for you, -Woody Michael Doube wrote: > Hi All > > I'm having trouble getting tidy menu items for my plugins. > > I followed the IJ-Eclipse best practice instructions from the IJ > conference in Luxembourg and started putting my plugins in packages, > e.g. in Fit_Sphere.java > > package org.doube.bone_geometry; > > But then I get lots of levels of menus before I can select a plugin, > which is a pain, e.g.: > Plugins>org>doube>bone_geometry>Fit Sphere > > So I wrote a plugins.config file, using these instructions: > https://list.nih.gov/cgi-bin/wa?A2=ind0804&L=IMAGEJ&P=R5626&I=-3 > http://imagejdocu.tudor.lu/doku.php?id=howto:plugins:howto_create_an_imagej_plugin_jar_file > > > But if I put this in my plugins.config: > Plugins>Bone Geometry, "Fit Sphere", > org.doube.bone_geometry.Fit_Sphere("") > > I get the menu entry Plugins>Bone Geometry>Fit Sphere, but running it > throws this exception: > Plugin or class not found: "org.doube.bone_geometry.Fit_Sphere > (java.lang.ClassNotFoundException: org.doube.bone_geometry.Fit_Sphere) > > Bone_Geometry.jar is saved in ~/ImageJ/plugins/ and plugins.config is > in the root directory of the jar, and all the class files are in > /org/doube/bone_geometry/ within the jar. > > How can I fix this? > > Cheers > > Mike > > |
Jeffrey B. Woodward wrote:
> When I package things, I put my jars that are equivalent to your > "Bone_Geometry.jar" in the directory ~/ImageJ/plugins/jars, and as you > said, I put the plugins.config in the root directory of said jar file. > > Hope that helps/works for you, Thanks Woody, but unfortunately it does not. Mike > > -Woody > > > Michael Doube wrote: >> Hi All >> >> I'm having trouble getting tidy menu items for my plugins. >> >> I followed the IJ-Eclipse best practice instructions from the IJ >> conference in Luxembourg and started putting my plugins in packages, >> e.g. in Fit_Sphere.java >> >> package org.doube.bone_geometry; >> >> But then I get lots of levels of menus before I can select a plugin, >> which is a pain, e.g.: >> Plugins>org>doube>bone_geometry>Fit Sphere >> >> So I wrote a plugins.config file, using these instructions: >> https://list.nih.gov/cgi-bin/wa?A2=ind0804&L=IMAGEJ&P=R5626&I=-3 >> http://imagejdocu.tudor.lu/doku.php?id=howto:plugins:howto_create_an_imagej_plugin_jar_file >> >> >> But if I put this in my plugins.config: >> Plugins>Bone Geometry, "Fit Sphere", >> org.doube.bone_geometry.Fit_Sphere("") >> >> I get the menu entry Plugins>Bone Geometry>Fit Sphere, but running it >> throws this exception: >> Plugin or class not found: "org.doube.bone_geometry.Fit_Sphere >> (java.lang.ClassNotFoundException: org.doube.bone_geometry.Fit_Sphere) >> >> Bone_Geometry.jar is saved in ~/ImageJ/plugins/ and plugins.config is >> in the root directory of the jar, and all the class files are in >> /org/doube/bone_geometry/ within the jar. >> >> How can I fix this? >> >> Cheers >> >> Mike >> >> |
In reply to this post by Michael Doube
>
> > How can I fix this? Is the class public? As in: public class Fit_Sphere ... { } If you have a constructor other than the default--FitSphere() is the default--, then you need to add the default as public, even if its body is empty: public FitSphere() {} Cheers, Albert -- Albert Cardona http://albert.rierol.net |
In reply to this post by Jeffrey B. Woodward
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Hello, I think there must be a misunderstanding somewhere. What I proposed in the best practices workshop is to separate the implementation of the plugin interface (let's call it A) from the code actually doing the work (let's call it B). A should only care about plugin specific things and use the api of B. A is in the default package and has an underscore in the name. B is not in the default package. B can be distributed over many packages each part being in a package according to what it does. The main advantage of this scheme is that the functionality of your code is available as a library, that can be used from any other code, without passing by the ImageJ "run" mechanism. To install your plugin, you can create a .jar containing all the packages used by B and put the jar and the class file of A in a subfolder of the plugin folder. Best regards, Volker Bäcker Jeffrey B. Woodward a écrit : > When I package things, I put my jars that are equivalent to your > "Bone_Geometry.jar" in the directory ~/ImageJ/plugins/jars, and as you > said, I put the plugins.config in the root directory of said jar file. > > Hope that helps/works for you, > > -Woody > > > Michael Doube wrote: >> Hi All >> >> I'm having trouble getting tidy menu items for my plugins. >> >> I followed the IJ-Eclipse best practice instructions from the IJ >> conference in Luxembourg and started putting my plugins in packages, >> e.g. in Fit_Sphere.java >> >> package org.doube.bone_geometry; >> >> But then I get lots of levels of menus before I can select a plugin, >> which is a pain, e.g.: >> Plugins>org>doube>bone_geometry>Fit Sphere >> >> So I wrote a plugins.config file, using these instructions: >> https://list.nih.gov/cgi-bin/wa?A2=ind0804&L=IMAGEJ&P=R5626&I=-3 >> http://imagejdocu.tudor.lu/doku.php?id=howto:plugins:howto_create_an_imagej_plugin_jar_file >> >> >> But if I put this in my plugins.config: >> Plugins>Bone Geometry, "Fit Sphere", >> org.doube.bone_geometry.Fit_Sphere("") >> >> I get the menu entry Plugins>Bone Geometry>Fit Sphere, but running it >> throws this exception: >> Plugin or class not found: "org.doube.bone_geometry.Fit_Sphere >> (java.lang.ClassNotFoundException: org.doube.bone_geometry.Fit_Sphere) >> >> Bone_Geometry.jar is saved in ~/ImageJ/plugins/ and plugins.config is >> in the root directory of the jar, and all the class files are in >> /org/doube/bone_geometry/ within the jar. >> >> How can I fix this? >> >> Cheers >> >> Mike >> >> > Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJgyCwxZKX7A/4oMERAo+HAJ0WAaRel7tmDWh1wpaHU9WJGpa2qgCdFNbq Td1Ujs8ih5yw5dcOHi9+dfg= =uD4s -----END PGP SIGNATURE----- -- passerelle antivirus du campus CNRS de Montpellier -- |
In reply to this post by Michael Doube
> How can I fix this?
More possible fixes: - check that your jar file has an underscore in its name. Otherwise it's not recognized as a plugin -- but I guess that is not the issue. - From the javascript window (Plugins - New - Javascript...), try: print(Class.forName("org.doube.bone_geometry.Fit_Sphere")); If the class is not found, the log window will throw an exception. This at least will tell you that the ImageJ classloader didn't pick up your jar, for some reason. Some related comments: - you don't need an underscore in the name of the class that implements PlugIn, if you are using plugins.config - you don't need to call the plugin with an empty string for arguments from the plugins.config, just use (note the lack of a trailing ("") ): Plugins>Bone Geometry, "Fit Sphere", org.doube.bone_geometry.Fit_Sphere For example, this is what I use for TrakEM2's plugins.config: Plugins>TrakEM2, "New Project (from template)", ini.trakem2.New_Project Albert -- Albert Cardona http://albert.rierol.net |
> - check that your jar file has an underscore in its name. Otherwise it's
> not recognized as a plugin -- but I guess that is not the issue. It is called Bone_Geometry.jar > > > - From the javascript window (Plugins - New - Javascript...), try: > > print(Class.forName("org.doube.bone_geometry.Fit_Sphere")); I get: sun.org.mozilla.javascript.internal.WrappedException: Wrapped java.lang.ClassNotFoundException: org.doube.bone_geometry.Fit_Sphere (<Unknown source>#1) in <Unknown source> at line number 1 > > Some related comments: > > - you don't need an underscore in the name of the class that implements > PlugIn, if you are using plugins.config I took the _ out, and called the class FitSphere, with no improvement. > - you don't need to call the plugin with an empty string for arguments > from the plugins.config, > just use (note the lack of a trailing ("") ): I took out the ("") too: no effect. If I remove / rename plugins.config everything works fine, I just get a deep menu to click through before I get to my plugins, so maybe I will go back to that and do my best to observe Volker's design guidelines. Thanks everyone, Mike |
Free forum by Nabble | Edit this page |