I have a task to check a set of conditions for unknown set of classes from classpath. I want to scan it for classes, load each of them and perform my checks. Now I have a set of urls to class files and I try to use URLClassLoader. But to load a class I need to specify a fully qualified class name, but I don't have them (I have only file path). I don't think that building class name from class file path is relieble, is it a better way to do it?
Thanks!
I'd just parse the beginning of the class file, looking for "package" keyword and first occurrence of "class" keyword. Then, when you combine those two (packageName + "." + className
), it should result in a proper class name.