Original Post
🔒 Locked
Emumerate Java Classes in a Package
Advertisement
Nothing like that exists in the core packages that I''m aware of. It can be implemented by extending the java.lang.ClassLoader abstract class an implementing the desired functionality. You can scan the classpath or any directories for existing class files (jar''ed or otherwise) and store them all in a List, for example.
Check out the jutils project at java.net. There''s a Plugin loader in there that does something similar to what you''re after. It is actually only loads classes that implement a Plugin interface, but if you look at the code you will see how it scans every class it finds to look for Plugins. It sholdn''t be to hard to modify it to store a list of ever class in a specific package.
Check out the jutils project at java.net. There''s a Plugin loader in there that does something similar to what you''re after. It is actually only loads classes that implement a Plugin interface, but if you look at the code you will see how it scans every class it finds to look for Plugins. It sholdn''t be to hard to modify it to store a list of ever class in a specific package.
Okay, so there isn''t an easy way - thanks for your responses. Is there a way that I can relate a package back to either a path or a path + jar file, so that I can limit the area I search (I know what package the classes should be in & they''d be relative to an interface class...so if I can get its path details that''d be useful) ?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement