943,929 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1333
  • Java RSS
Dec 9th, 2006
0

Java

Expand Post »
How to run a java program without main function.
Similar Threads
Reputation Points: 13
Solved Threads: 0
Newbie Poster
farook ahammad is offline Offline
5 posts
since Sep 2006
Dec 9th, 2006
0

Re: Java

there is no "main function" in Java, only a "main method".
It is required to have the exact signature "public static void main(String[] args)" or a lexical equivalent (it can for example be made final, or you may use another name instead of args).

Without that the JVM will not start executing the program.

There is one way to get something done, but that's NOT running a program.
That way involves creating a static initialiser block in the class, which will be executed at class loading time.

This smells horifically like a homework question so I won't show you how to do it
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Dec 9th, 2006
0

Re: Java

you can run it without main method, but then it have to be Applet

Am'I correct jwenting?
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Dec 9th, 2006
0

Re: Java

An applet isn't technically a program
Same as a servlet or an EJB, both of which run without a "main" method.
Same for a SOAP service.
All can exist only within a specific runtime environment, and are effectively plugins to that environment.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: How to include txt into jar file?
Next Thread in Java Forum Timeline: I want to run my jsp page online on internet





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC