[Gvsig_desarrolladores] gvSIG extension path
César Martínez Izquierdo
cesar.martinez en iver.es
Mie Nov 8 16:48:53 CET 2006
erwan bocher wrote:
> Hi,
>
> I'd like to display the path where my extension is saved like
> D:/gvsig/linux/workspace/gvSIG
> -1_0-rc1-src/extGeoSQLBuilder/.
>
> I use this method :
>
> System.out.println(GeoSQLBuilder.class.getClassLoader ().getResource("./"));
>
> It work fine in eclipse debug environment but not when my extension (in
> jar) is in the gvsig extension folder. I have a null value. I don't
> understand why.
>
> Any ideas are welcome.
>
> Cheers
>
> R1.
>
Do you really want to know the extension's project dir
("D:/gvsig/linux/workspace/gvSIG-1_0-rc1-src/extGeoSQLBuilder/")
or the dir where the extension is installed
("D:/gvsig/linux/workspace/gvSIG-1_0-rc1-src/_fwAndami/gvSIG/extensiones/packageName/")?
If you want to get the second option, you can use:
ClassLoader loader = this.getClass().getClassLoader();
if (loader instanceof PluginClassLoader) {
// this should be always true if we are in an extension
PluginClassLoader ploader = (PluginClassLoader) loader;
System.out.println(loader.getPluginName());
}
This justs gets the extension's packageName.
If you wish the full extension's dir, you can use:
System.out.println(PluginServices.getPluginServices(this).getPluginDirectory().getAbsolutePath());
Best regards,
César
Más información sobre la lista de distribución gvSIG_desarrolladores