2
I’m needing to take all the classes of a certain package, I’ve seen some codes that do this, but it only takes the classes that are part of the project itself, basically doesn’t use Reflection and does a search for files .class
in the directory, in my case, I need to pick up the .class
of a jar that is part of my project.
Something like:
List<Class> clazz = ReflectionUtil.getClassFromPackage("org.springframework.util");
List<Class> clazz = ReflectionUtil.getClassFromPackage("com.meuprojeto.meupacotebase");
I’ve already tried:
http://mike.shannonandmike.net/2009/09/02/java-reflecting-to-get-all-classes-in-a-package/
https://stackoverflow.com/questions/15519626/how-to-get-all-classes-names-in-a-package
https://stackoverflow.com/questions/520328/can-you-find-all-classes-in-a-package-using-reflection
https://stackoverflow.com/questions/520328/can-you-find-all-classes-in-a-package-using-reflection
They spoke of that library http://github.com/ronmamo/reflections
but it has the following code:
Reflections reflections = new Reflections("my.project");
Set<Class<? extends SomeType>> subTypes = reflections.getSubTypesOf(SomeType.class);
Now, I need to get the list of classes, I don’t want to specify the type of class I need
I think this would be or should be basic with the Reflection java.
Man, very good, this is exactly what I wanted, it worked out, I had not gotten by this detail that you said new Subtypesscanner(false), beautiful explanation, again, thank you so much for the help!
– Rodrigo Rodrigues