As Java does to find out which is the main class in a file .jar
As Java does to find out which is the main class in a file .jar
He does not find out.
The.jar
usually includes a file named Manifest.mf
that is inside the META-INF
folder and contains a line indicating which is the executable class, similar to this:
Main-class: nome.do.pacote.ClasseExecutavel
As @Techies reported, it should contain this method:
public static void main(String [] args)
and should be in the nome/do/pacote/ClasseExecutavel.class
folder.
(Taken from: link )
When we develop a system in Java we have to have a starting point. Imagine a system where you have hundreds of classes and thousands and methods. Do we have to start from somewhere right?
That's why the JVM Java virtual machine will look for the MAIN
method on your system.
In short, the main class is the one that contains this statement:
public static void main(String [] args)
Here has an article where you can perhaps better understand.