0
Can we run program without main method in Java?
Java Question
2 Answers
+ 4
If you wish to include Android apps, the code you write in Java does not have a main method. There still is one. It is just part of the supplied code libraries of the generic Android app.
All programming languages must have some form of entry point to pick where they start running from. Java uses a main method. Python picks the first line of the source file. These things are fixed and can't be changed without rewriting the compiler or interpreter for the language.
+ 4
According to my knowledgeĀ weĀ cannot executeĀ withoutĀ aĀ main methodĀ because when yourĀ runningĀ theĀ java program.Ā javaVirtual machine look for theĀ main method.if JVMĀ couldĀ not find theĀ main methodĀ itwillĀ show youĀ runĀ time error Exception in threadĀ main couldĀ not find theĀ mainclass.