It's not a secret anymore!*
The moose likes Java in General and the fly likes Using reflection to find all classes in a given package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Using reflection to find all classes in a given package" Watch "Using reflection to find all classes in a given package" New topic
Author

Using reflection to find all classes in a given package

Suhaasi Karnik
Greenhorn

Joined: Mar 15, 2004
Posts: 23
Hi,

Is it possible to find out all classes and/or subpackages of a given package using reflection?

Thanks in advance,
Suhaasi
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

There's no API to do it directly. However you can find out the package for a particular classs, and you can trawl through all classes in your classpath.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using reflection to find all classes in a given package