How to find class that contains main method in a package/jar using reflection?

1.1k Views Asked by At

I am using dynamic class loading which requires the main class for loading the classes. If have a package/jar i want to get the class name that contains main method? Is it possible with Reflection? or is there any other API?

Is there any method like java.net.JarClassLoader.getMainClassName() for packages too.

1

There are 1 best solutions below

3
On

You need a firm and first entry point (main method) then you can make all calls dynamically via reflection.