How to create a pluginable Java program?

后端 未结 6 1803
粉色の甜心
粉色の甜心 2020-12-12 13:48

I want to create a Java program that can be extended with plugins. How can I do that and where should I look for?

I have a set of interfaces that the plugin must imp

6条回答
  •  旧巷少年郎
    2020-12-12 14:34

    Although I'll second the accepted solution, if a basic plugin support is needed (which is the case most of the time), there is also the Java Plugin Framework (JPF) which, though lacking proper documentation, is a very neat plugin framework implementation.

    It's easily deployable and - when you get through the classloading idiosynchrasies - very easy to develop with. A comment to the above is to be aware that plugin loadpaths below the plugin directory must be named after the full classpath in addition to having its class files deployed in a normal package path named path. E.g.

    plugins
    `-com.my.package.plugins
      `-com
        `-my
          `-package
            `-plugins
              |- Class1.class
              `- Class2.class
    

提交回复
热议问题