import ij.*; import ij.plugin.*; import java.net.*; import java.security.*; /** This plugin demonstrates how to use the Class.getProtectionDomain() method to get the location of a plugin. It requires ImageJ 1.43, which has an enhanced PluginClassLoader contributed by Kevin Moll. */ public class Plugin_Locator implements PlugIn { public void run(String arg) { if (IJ.versionLessThan("1.43b")) return; showLocation(this.getClass()); String name = "Kalman_Stack_Filter"; try { showLocation(Class.forName(name)); } catch(Exception e) { IJ.log(""+e); } // You can also use Class.getResource() to get the location URL url =getClass().getResource(name+".class"); if (url!=null) { String path = url.toString().replaceAll("%20", " "); IJ.log(name+": "+path); } else IJ.log(name+" not found"); } void showLocation(Class aClass) { ProtectionDomain domain = aClass.getProtectionDomain(); CodeSource source = domain.getCodeSource(); URL location = source.getLocation(); if (location!=null) { String path = location.getFile().replaceAll("%20", " "); IJ.log(aClass.getName()+": "+path); } else IJ.log(aClass.getName()+": not found"); } }