How do I find the (class) path to plugin libraries

How do I find the class path that's used by my plugin?
I'm starting a separate JVM from the plugin and I'd like it to use the libraries I also use in the plugin. So I need to set the correct class path(s).
Currently for testing I'm just adding the absolute paths of the library jars to the command line classpath option.

Should I attach the respective jars as a separate resource? That doesn't seem like the correct approach.

Is there another way to spawn a new JVM and give it the appropriate classpath that points to all the libraries I use in the plugin or otherwise specify library dependencies for that java process that I'm missing here?

2 comments
Comment actions Permalink

This is how I'm doing it for now. If someone knows a better way, please let me know...

   private String findLibPath()
   {
      // FIXME find a cleaner way for getting at the libraries class path
      final Path path = Paths.get(PathUtil.getJarPathForClass(this.getClass()));
      if (path.endsWith("classes")) return path.resolve("../lib")
            .normalize()
            .toString();
      return Paths.get(PathUtil.getJarPathForClass(getClass()))
            .getParent()
            .toString();
   }

0
Comment actions Permalink

have you seen these?

com.intellij.openapi.application.PathManager#getPluginsPath

com.intellij.openapi.application.PluginPathManager#getPluginHome
0

Please sign in to leave a comment.