简体   繁体   中英

Loading classes that extend another class from jars in directory

What I want to do is , let's say I have a folder , and that is a directory, and let's say I created a JAR that has a class in there that is extending "Apple". How would I check ALL JARS in that folder and check that they have class extending Apple, THEN add each and every one of those classes extending apple to my List?

You have to use reflection API for this. First, get list of all classes loaded by class loader and then with the help of reflection API, you can check if a class extends Apple or not. Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM