Plugin location Permanently deleted user Created September 02, 2011 14:34 Is there a "proper" way to find the path to the plugin installation directory at runtime?Will this be the way to go?PluginManager.getPlugin(PluginId.getId("myplugin")).getPath()
Hi Anton,
Have you tried PluginClass.class.getProtectionDomain().getCodeSource().getLocation() ?
Regards, Denis
Tried it now, thx. Gives the same result as if I used PluginManager
Don't have better answer at the moment then.
Btw, why would you need that information?
Denis
I'd like to refer a file in the plugin installation.
Let's say I have a plugin structure:
- plugin.jar
- agent.jar
then, the plugin should set a system property for a Java process automatically (already done), e.g.:
java -javaagent:C:/users/anton.IntelliJIDEAx0/plugins/Sample/lib/agent.jar
What is returned by ...CodeSource().getLocation() and PluginManager.getPlugin(PluginId.getId("myplugin")).getPath() ? null?
You can get path to the root plugins dir via PathManager.getPluginsPath() then and manually filter your plugin data there.
Denis
PluginManager.getPlugin(PluginId.getId("myplugin")).getPath() returns the path - all is fine. Probably I did something wrong at my first tries. thx!
I have this utility method which I most likely got from somewhere in the CE sources. It uses the same technique as in your example.