title: Java dynamically load plugin
body: <p>I want to make an application that can dynamically load plug-ins but I've not found any literature on Internet.</p>
  
  <p>The difficult thing is: I don't know the name in advance.</p>
  
  <p>For example I've a <strong>Plugin</strong> interface:</p>
  
  <pre><code>public interface Plugin {
      public static Plugin newPlugin();
      public void executePlugin(String args[]);
  }
  </code></pre>
  
  <p>So that every Class implementing <strong>Plugin</strong> in the jar file are instantiated in a list:</p>
  
  <pre><code>Method method = classToLoad.getMethod ("newPlugin");
  mylist.add(method.invoke(null);
  </code></pre>
  
  <ol>
  <li>First problem is, I cannot have a <strong>static</strong> method in an interface.</li>
  <li>Second problem is, I don't know how to find all classes that implement an interface</li>
  </ol>
  
  <p>Thanks for your help.</p>