Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List of packages and classes within packages?

Status
Not open for further replies.

AdamRice32

Programmer
Dec 31, 2001
38
US
Hi All,

Does anyone know if there's a way to get a list of all packages in a ClassLoader, and also a list of all of the classes within each package? I imagine that this is possible because several IDEs do it (Forte, for example).

Other than extending ClassLoader and using the protected getPackages() method, I don't see a way of doing this using the standard API.

Any thoughts?

Thanks,
Adam Rice
 
Okay, so a follow-up if anyone's interested... there's a static getPackages() method in the Package class that returns an array of all Package objects in the caller's class loader.

However, I still cannot find a way to get a list of all of the classes in a particular package. You might think there would be an instance method in Class named getClasses() or something similar to do this, but alas there is not.

Any input is appreciated.

Thanks,
Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top