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?

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")
      return Paths.get(PathUtil.getJarPathForClass(getClass()))

Comment actions Permalink

have you seen these?



Please sign in to leave a comment.