Hoe can I detect the main class of my application? The one, which is either given on the command line or loaded from the jar given at the command line?
If this is not possible, why not?
EDIT: Maybe I wasn’t clear. I know there always can be many entry points into my app, but while the app is running, there was only one entry point used to start the current JVM. This is the one I need to know of.
First of all, an application can have several entry points. It is simply a class that contains a public static method called main with the argument type
String[].So, short answer, no, there may be several possible entry points of a set of classes.
If you want to list all entry points of an application, you would simply need to iterate over the classes and look for such main method.
If you create a “runnable jar-file” however, there will be an entry in the Manifest file looking like
which specifies the main class of the application.