Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes public static void main(String agrs[]) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "public static void main(String agrs[])" Watch "public static void main(String agrs[])" New topic
Author

public static void main(String agrs[])

minal silimkar
Ranch Hand

Joined: Nov 25, 2007
Posts: 133
java main() method is in which class?


Minal Silimkar
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

It is in whichever class you put it in

A Java application needs a main method to start. This is the interface the Java runtime uses to call into your code.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Piyush Porwal
Ranch Hand

Joined: Apr 09, 2008
Posts: 30
or what he means to say is: if you fire "java ClassName", ClassName should have this.


-Piyush Porwal (Junk box)
minal silimkar
Ranch Hand

Joined: Nov 25, 2007
Posts: 133
Originally posted by Paul Sturrock

It is in whichever class you put it in

A Java application needs a main method to start. This is the interface the Java runtime uses to call into your code.


Thank you Paul. I thought, main() is necessary to run the program, so it must me somewhere mentioned in bulit-in classes
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32675
    
    4
Originally posted by minal silimkar:
Originally posted by Paul Sturrock


Thank you Paul. I thought, main() is necessary to run the program, so it must me somewhere mentioned in built-in classes
No, none of the built-in classes has a main method, because none of the built-in classes is designed as the starting point for an application. You write a class which starts off your application, and you write a main method for the JVM to start with.
minal silimkar
Ranch Hand

Joined: Nov 25, 2007
Posts: 133

Originally posted by Campbell Ritchie

No, none of the built-in classes has a main method, because none of the built-in classes is designed as the starting point for an application. You write a class which starts off your application, and you write a main method for the JVM to start with.


Thank you Campbell, for detailed explaination.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: public static void main(String agrs[])
 
Similar Threads
First GUI program
packaging runme.jar
WA #1.....word association
run time error
java.lang.NoSuchMethodError