The old-style solution for this problem is to define an interface that all plugins should implement. Then use Reflection to load this class and apply it to the interface. If an exception does not occur, you can now safely call the method from the interface. This approach has the disadvantage that the class must be accessible in the class path at the beginning of the application.
A more “modern” and dynamic approach to plugins in the Java OSGI world . Eclipse uses OSGI for its plugin system and allows you to add and remove plugins at runtime.
source
share