I want to print all the class names in a package and also to print the corresponding attributes and their data types in each package.
In one code, I am able to get t
If the fully-qualified name of a class is available, it is possible to get the corresponding Class using the static method Class.forName().
Eg:
Class c = Class.forName("com.duke.MyLocaleServiceProvider");
Note: Make sure the parameter you provide for the function is fully qualified class name like com.package.class
Check here for any reference.
EDIT:
You could also try using loadClass() method.
Eg:
ClassLoader cl;
Class c = cl.loadClass(name);
It is invoked by the Java virtual machine to resolve class references.
Syntax:
public Class> loadClass(String name)
throws ClassNotFoundException
For details on ClassLoader check here
Here is an implementation of ClassLoader.