title: Java SPI JARs not loaded from directory without setting -Djava.ext.dirs
body: <p>I can't get the Service Provider Interface to load an implementation from another JAR in the same directory. It only works when I use -Djava.ext.dirs=. on the command line. Should it not work without?</p>
  
  <p>I have the following interface:</p>
  
  <pre><code>package playground;
  
  public interface TestIface {
      public String test();
  }
  </code></pre>
  
  <p>which is implemented here:</p>
  
  <pre><code>package playground;
  
  public class TestImpl implements TestIface {
      public String test() {
          return "TEST";
      }
  }
  </code></pre>
  
  <p>Here I try to load the implementation: </p>
  
  <pre><code>package playground;
  import java.util.Iterator;
  import java.util.ServiceLoader;
  public class Lalala {
      public static void main(String[] args) {
          ServiceLoader&lt;TestIface&gt; loader = ServiceLoader.load(TestIface.class);
          Iterator&lt;TestIface&gt; it = loader.iterator();
          while (it.hasNext()) {
              TestIface a = it.next();
              System.out.println(a.test());
          }
          System.out.println("DONE");
      }
  
  }
  </code></pre>
  
  <p>The interface and the last class are packaged in main.jar, the implementation in impl.jar. 
  main.jar has the Main class set and impl.jar has the META-INF/services/playground.TestIface file which contains "playground.TestImpl". Both JARs are in the same directory.
  Running</p>
  
  <pre><code>java -jar main.jar
  </code></pre>
  
  <p>only prints "DONE", the implementation apparently is not found.</p>
  
  <p>If I instead run</p>
  
  <pre><code>java -Djava.ext.dirs=. -jar main.jar
  </code></pre>
  
  <p>it also prints "TEST" as it should.</p>
  
  <p>What am I doing wrong? Why is the implementation from the other JAR not loaded unless I change the java.ext.dirs setting?</p>