I really did a lot of research before asking this, it seems like I'm missing something. I try to implement a ServiceLoader and therefore made an example class:
the code is simple:
testInterface.java
package com.test;
public interface testInterface {
void test();
}
testImpl.java
package com.test;
public class testImpl implements testInterface {
@Override
public void test() {
System.out.println("test");
}
}
Main.java
package com.test;
import java.util.ServiceLoader;
public class Main {
public static void main(String[] args) {
ServiceLoader<testInterface> serviceLoader = ServiceLoader.load(testInterface.class);
serviceLoader.iterator().next().test();
}
}
com.test.testInterface
com.test.testImpl
I keep getting a NoSuchElementException at the iterator part which means that the implementation was not loaded. Thanks in advance.