| Author |
Is it possible to have two main methods in one Java Project?
|
Varuna Seneviratna
Ranch Hand
Joined: Jan 15, 2007
Posts: 164
|
|
|
Is it possible to have two main methods in one Java Project?
|
Varuna Seneviratna
|
 |
Singh Harmeet
Ranch Hand
Joined: Aug 05, 2011
Posts: 114
|
|
|
yes it is possible, because main is also a user define method , but its defenation is define in jvm and this method is call by jvm like simple methods call........
|
With Regards :-
Harmeet Singh
|
 |
Ninad Kulkarni
Ranch Hand
Joined: Aug 31, 2007
Posts: 780
|
|
Hi Varuna,
When you run java program from command line main method is entry point. There is no restriction for main method.
|
SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3865
|
|
|
You can have as many as you like (as long as they aren't on the same class). The class you want to execute the main method on is specified as part of the execution command (unless you've created an executable Jar file, in which case it's specified in the manifest file).
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 10043
|
|
Matthew Brown wrote:You can have as many as you like (as long as they aren't on the same class).
i think you can have more than one main method in a class, as long as they have different signatures - just like any other method.
|
 |
 |
|
|
subject: Is it possible to have two main methods in one Java Project?
|
|
|