ServiceLoader issues and locating folders inside the plugin


I have written a plugin that is packed using the third option in

      ... other jars and xml files ...



However, I am facing some difficulties when the following code is executed:



It returns an empty Iterable, even though I am distributing my implementation in the same lib folder.

2) How do I fetch the path to myrepository ? This folder is packed together with my plugin.

Forgive me if these questions are too trivial, this is the first time I write an IDEA plugin.

My source is located in

Best Regards,

George Gastaldi


Hi George,

ServiceLoader can't find your classes because plugin's classes are loaded by a dedicated classloader and system classloader doesn't know about that. Anothe question is why do you use ServiceLoader at all?

You can use com.intellij.openapi.application.PathManager.getPluginsPath() to get information about plugins root dir and then navigate by the known relative path.



Hi Denis,

Thanks for the response. I use ServiceLoader because it's the way I designed the integration between my interface API and class IMPL.

As for the PathManager usage, what is the best way to retrieve the folder my plugin was installed INSIDE the folder specified by PathManager.getPluginsPath() ?

Best Regards,

George Gastaldi


Your plugin jar should be located at that plugins directory



Please sign in to leave a comment.