Dynamically loading plugin jars using ServiceLoader

后端 未结 3 767
南笙
南笙 2020-12-02 07:12

I\'m trying to create a plugin system for my application, and I want to start with something simple. Every plugin should be packed in a .jar file and implement the Sim

3条回答
  •  情书的邮戳
    2020-12-02 07:58

    The solution for your application concept has been already described in Oracle Documentation (including dynamically loading JARs)

    Creating Extensible Applications With the Java Platform http://www.oracle.com/technetwork/articles/javase/extensible-137159.html

    on the bottom of the article you will find links to

    • source code of the example
    • Javadoc ServiceLoader API

    In my opinion it is better to slightly modify Oracle's example than reinventing the wheel as Omer Schleifer said.

提交回复
热议问题