title: Get SubTypes in Java with Reflections library
body: <p>I try to get classes that implements an interface in a given package, using <a href="https://github.com/ronmamo/reflections" rel="nofollow noreferrer">reflections library</a>. </p>
  
  <p>I have the following code : </p>
  
  <pre><code>package TestClass;
  
  import org.reflections.Reflections;
  
  import org.reflections.scanners.SubTypesScanner;
  
  import java.io.DataInputStream;
  import java.io.InputStream;
  import java.net.URL;
  import java.util.*;
  
  public class Checks {
      public static void main(String[] args) {
          Reflections reflections = new Reflections("TestReflection.src.testclass");
          try{
              Set&lt;Class&lt;? extends CheckingClass&gt;&gt; classes = reflections.getSubTypesOf(CheckingClass.class);
          }catch(Exception e){
              System.out.println(e.toString());
          }
      }
  }
  </code></pre>
  
  <p>It gives me this error : <code>org.reflections.ReflectionsException: Scanner SubTypesScanner was not configured</code></p>
  
  <p>It surprises me because i got the code from an example of how to use reflections library, so it should work. 
  The library, i think, is well imported because other methods work. 
  I've tried a lot of things and can't make this code work. </p>
  
  <p>Maybe i'm missing an important details. Any idea? </p>
  
  <p>Thanks</p>
  
  <p>EDIT : Here's the tree of my project, so you can see if my path is good : </p>
  
  <p><a href="https://i.stack.imgur.com/yHzEV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yHzEV.png" alt="enter image description here"></a></p>
  
  <p>EDIT 2 : I changed </p>
  
  <p><code>Reflections reflections = new Reflections("TestReflection.src.testclass", new SubTypesScanner());</code> </p>
  
  <p>to</p>
  
  <p><code>Reflections reflections = new Reflections("testclass", new SubTypesScanner());</code> </p>
  
  <p>and i have an other error : </p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
      at org.reflections.adapters.JavassistAdapter.getOrCreateClassObject(JavassistAdapter.java:107)
      at org.reflections.adapters.JavassistAdapter.getOrCreateClassObject(JavassistAdapter.java:34)
      at org.reflections.scanners.AbstractScanner.scan(AbstractScanner.java:28)
      at org.reflections.Reflections.scan(Reflections.java:270)
      at org.reflections.Reflections.scan(Reflections.java:216)
      at org.reflections.Reflections.&lt;init&gt;(Reflections.java:137)
      at org.reflections.Reflections.&lt;init&gt;(Reflections.java:182)
      at org.reflections.Reflections.&lt;init&gt;(Reflections.java:155)
      at testclass.Checks.main(Checks.java:12)
  Caused by: java.lang.ClassNotFoundException: javassist.bytecode.ClassFile
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
      at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
      ... 9 more
  
  Process finished with exit code 1
  </code></pre>