Login  Register

get directory for a class instance

Posted by Ben.BigHair on Jul 12, 2007; 12:28pm
URL: http://imagej.273.s1.nabble.com/get-directory-for-a-class-instance-tp3698874.html

Hello,

Is there a means to get the the directory of a plugin from an  
instance of that plugin?  I imagine something terribly easy like...

        String thisPluginPath = IJ.getDirectory("thisPluginInstance");

I ask because I have a plugin to distribute that includes a user  
preferences file - the dialog for the plugin requires a lot of user  
input.  The input might remain essentially the same for days but at  
another time change significantly at for each use.  The trouble is  
finding the preference file relative to the plugin class file when I  
don't know where the plugin is located.  For example...

User 1 places the plugin and preference file in /plugins/ben/ .... while
User 2 places the plugin and preference file in /plugins/tom/

I have no control over this and you can imagine the troubles this  
might cause.  I realize that ImageJ has a user preference system  
which could be used for this purpose, but I prefer to to keep these  
separate from that system.  I prefer to avoid searching all of the  
plugin directories for the class name except as a last resort.

Thanks!
Ben

Ben Tupper
Bigelow Laboratory for Ocean Science
180 McKown Point Road
POB 475
West Boothbay Harbor, ME 04575