In C# you can easily read all classes from a given assembly.
I’m looking for equivalent feature in Java. I need this to automatically bind EJB beans to my Guice Module.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unfortunately there seems to be no ready-to-use solution in Java.
In our project we used a slightly modified approach suggested by some blog. The solution described there is to scan file system and JARs for classes.
If you want to pick only classes implementing some interface, you can do some additional check like
clazz.isAssignableFrom(MyInterface.class).