[Solved] java string to class and call mathod


First you have to know the name of the package containing the class. If you know it, you can try the following:

String className = packageName + ".Test";
Class cls = Class.forName(className);
cls.getMethod("main", String[].class).invoke(null);

Note that, if the class is in (default) package then you can use “Test” as className without the package name.

2

solved java string to class and call mathod