I have an issue with loading classes via Class.forName(String className)
when I amtrying to get a class from another package. It keeps throwing a ClassNotFoundException
, even though I am fully declaring qualified (package) names as the class name.
Is there any way to load classes from another package?
Basically, what I am trying to do is load a bunch of different class files using a configuration. This isn't explicitly necessary (I'm just fooling around with code) but I would like to know if this is possible or not.
As a last note, I am fairly new to code development, having only just begun back in November, with Java as my first language.
It is totally possible. Two things to check:
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.