File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How to determine all classes in current class loader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to determine all classes in current class loader" Watch "How to determine all classes in current class loader" New topic
Author

How to determine all classes in current class loader

Chris Nappin
Ranch Hand

Joined: Aug 04, 2005
Posts: 36
I would like to be able to get a list of all classes that can be loaded by the current class loader, so that I can then inspect them looking for specific annotations - like a Java EE 5 container does, but all the code would be sitting inside an application, not in the container. Is this possible in a reliable, portable manner in a J2EE container environment? I imagine hacks to locate physical .jar/.ear/.war files won't work accross containers, when some expand them and others don't?

Does anyone know if any of the AOP or byte-code manipulation libraries (cglib, BCEL, ASM etc) have APIs that might help here?


Technical Architect, SCJP, SCWCD
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
No, I don't think there's any nice generic way to do this. You have to do something specific to the type of ClassLoader you're using.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to determine all classes in current class loader
 
Similar Threads
Dynamic classloading without .forName/.newInstance
java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
How can I set current class loader
Reloading a new version of a class
Inter Servlet Communication- Doubts