Java : loop on all the classes in the classpath

classpath, java, reflection

Solution

The Reflections library helps deal with this problem. As others have stated, it isn't fully possible in all class loading situations, but if all you have are jars and files, this will do it reliably.

Problem

Is there a way to iterate over all the classes in the classpath ? I want to make some reflective checks on some classes implementing a certain interface, but I want to do it completely dynamically, without any input on which classes to check, just browsing the classpath.

Original source

Related problems