Is it possible to get all the subclasses of a clas

2020-02-06 05:14发布

Possible Duplicate:
How do you find all subclasses of a given class in Java?

Hi,

I would like to get a list of classes that implement an interface in Java at runtime so I can do a lookup service without having to hard code it. Is there a simple way of doing this? I fear not.

8条回答
Summer. ? 凉城
2楼-- · 2020-02-06 05:50

If you only load classes from the disk or from URLs then you can scan the classpath and find subclasses "manually".

查看更多
Juvenile、少年°
3楼-- · 2020-02-06 05:55

It's fairly simple using reflection. Read this article from JavaWorld

http://www.javaworld.com/javaworld/javatips/jw-javatip113.html

查看更多
登录 后发表回答