This content has been marked as final. Show 5 replies
- create JVM instance
- load class(es)
- locate public static main(String) method
- make JVM instance execute it
Its all in the source of the java wrapper executable if you really must know. Me - I wouldn't care about it.
most of the java books just tell that jvm starts the main method....some wrote that user thread (called main)is created then from that thread just main method is invoked. Is it possible to know the internal mechanism of invoking the main method..
983265 wrote:Both description seems plausible. Just different levels of details. Neither is complete (a previous answer mentioned loading and initializing classes), it's merely the appropriate level of abstraction for the majority of us that are essentially interested in having their main() (and all other application code) executed.
most of the java books just tell that jvm starts the main method....
some wrote that user thread (called main)is created then from that thread just main method is invoked
Is it possible to know the internal mechanism of invoking the main method...There is probably no such thing as the mechanism, as different JVM implementations could probably choose different approaches.
If you need to know the exact specifications that all JVMs must comply with, look for the JVM specifications, in particular this chapter http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-5.html#jvms-5.2 (which mentions the freedom of implementation choices)
But again, why do you ask?
"Just out of curiosity" is a valid answer, but "because my program will sorely depend on this mechanism" would sound suspicious.
This explains how an arbitrary application can invoke the java VM. This is also how java itself invokes it, probably with a lot of detail omitted.
Just for the curiosity... nothing else..
Anyway thanx for the links..