Java

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2006
Posts: 5
Reputation: farook ahammad is an unknown quantity at this point 
Solved Threads: 0
farook ahammad farook ahammad is offline Offline
Newbie Poster

Java

 
0
  #1
Dec 9th, 2006
How to run a java program without main function.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Java

 
0
  #2
Dec 9th, 2006
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
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,272
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 493
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: Java

 
0
  #3
Dec 9th, 2006
you can run it without main method, but then it have to be Applet

Am'I correct jwenting?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Java

 
0
  #4
Dec 9th, 2006
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum


Views: 1176 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC