2

What's a good way of adding a plugin interface such that it's possible to have optional components?

I'm aware of the Class.forName() approach (used with JDBC for example) but there is also this approach to dynamic class loading.

James P.
  • 19,313
  • 27
  • 97
  • 155
  • Huh? Dynamic class loading uses `Class.forName()`! – Stephen C May 16 '10 at 09:09
  • It would seem so. Question edited. Here's an article that explains the differences between the two: http://www.javaworld.com/javaworld/javaqa/2003-03/01-qa-0314-forname.html – James P. May 16 '10 at 09:34

1 Answers1

2

You may have a look at this: http://jpf.sourceforge.net/.

A good approach would be to load jar files in a specified directory at runtime and look if they contain plugin classes. Have a look at this: How to load a jar file at runtime.

Community
  • 1
  • 1
Simon
  • 9,255
  • 4
  • 37
  • 54