Login  Register

Re: placement of non-plugin utility classes

Posted by Ben.BigHair on Jul 19, 2006; 3:49pm
URL: http://imagej.273.s1.nabble.com/placement-of-non-plugin-utility-classes-tp3702100p3702102.html

Wayne Rasband wrote:

>> Hello,
>>
>> I am trying to reconcile what I learned in a recent Java training
>> course with what I am learning about ImageJ.  One piece that is quite
>> fuzzy in my mind is the placement of my own non-plugin utility
>> classes.  Suppose I had a utility class, "MyArrayUtilityClass",that
>> works with arrays in some generic way (other examples might be string
>> or file utilities)  .  Where in the world do I put it so I can import
>> it for my own ImageJ plugins.  Literally, where do I place the class
>> relative to the ImageJ application and what does the import statement
>> look like?
>
> To avoid class name conflicts, utility classes should be in packages.
> There is an example at
>
>      http://rsb.info.nih.gov/ij/plugins/packages.html
>
> Utility classes and JAR files go in the plugins folder.
>

Hi,

This works very easily. I have a follow-up question.  But first I should
describe what I have done so far.

I can get the following plugin
        ImageJ/plugins/Ben/myPlugin_.class

to work with
        ImageJ/plugins/Ben/benutil/myUtility.class

using the package declarations and syntax like in the example...

package benutil;
        <other stuff>
someResult = benutil.myUtility.myMethod();


I was thinking that I could place the utility class in the
        ImageJ/plugins/Utilities/myUtility.class

That would change the package and method call to

package Utilities;
        <other stuff>
someResult = Utilities.myUtility.myMethod();

But myUtility.class is not found when I run
        ImageJ/plugins/Ben/myPlugin_.class

It seems that the package has to reside within the directory (or
subdirectory) where myPlugin.class resides.

So my question what is the conventional organization of projects within
the ImageJ/plugins/ so that utility classes are universally accessible?

Thanks and cheers,
Ben