Login  Register

Re: Path problem?

Posted by Michael Doube on Jan 18, 2010; 10:31am
URL: http://imagej.273.s1.nabble.com/Path-problem-tp3689668p3689678.html

Hi Bob,

I've had similar problems in the past but now:

1) Implement PlugIn within packages
2) Call methods from other PlugIn classes in other sub-packages
3) Call methods and use classes from imported .jars

This is really very convenient and means I can reuse code between my
plugins, as well as have some non-PlugIn utility classes (but my code
is, shall we say, a bit "agricultural")

(Though I now better understand Volker's preference to have the PlugIns
in the root directory, calling classes in the packages - the PlugIn
classes talk to ImageJ's API and the other classes, which "do the work".
http://n2.nabble.com/plugins-config-Plugin-or-class-not-found-exception-tp2245232p2245464.html).

The special sauce is in plugins.config (which is sensitive to whitespace
incidentally, you must use space and not tab).

A PlugIn in the root directory of my jar is referred to in
plugins.config like this:
Plugins>BoneJ, "Fit Sphere", Fit_Sphere

It gets the menu item Plugins->BoneJ->Fit Sphere

A plugin in a package directory is referred to like this:
Plugins>BoneJ, "Moments 3D", org.doube.bonej.Moments

It gets the menu item Plugins->BoneJ->Moments 3D

I think Stephan covered the rest; importing classes for use in your new
PlugIn goes like:
import org.doube.util.ResultInserter;

I hope these tips help,

Michael


On 18/01/2010 09:13, Volker Baecker wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
> for ImageJ the plugin (i.e. the class that implements the PlugIn
> interface) must not be in any package. Therefore it can not be imported
> from anywhere else.
> IMHO the best thing to do is to put the code into another class that can
> be in a package and to import this package into the two plugins.
> Volker
>
> Bob wrote:
>> I recently started using ImageJ and Java (I am an experienced C++ programmer).  I am working on WinXP, SP3, ImageJ 1.42q, and Java 1.6.0_16.  I wrote my first plugin, and that went smoothly.  When I wrote the second plugin, I needed methods from the first plugin, so I imported it.  When I try to compile it, I get the error message "Package XYZ_ does not exist", pointing to the import line.  I am guessing the problem is that the compiler cannot find the XYZ_.class file.  I have added the path to the folder containing the file to the system variable PATH, but this did not resolve the problem.  Does anybody know how to get the compiler to link this file?
>>
>> Thanks to anyone who can help.
>>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAktUJisACgkQ0gXPLVKexCcbkQCfc8hWquZiG8UYATtBzM6X8y5B
> NpIAmgOdR8QaB/8HRk5V1YOsUiYFSPpb
> =3WDY
> -----END PGP SIGNATURE-----
>