| | |
Java
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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
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.
you can run it without main method, but then it have to be Applet
Am'I correct jwenting?
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
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
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.

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.
![]() |
Similar Threads
- Java 3D Environment (Java)
- Java 3D (Java)
- Java Expert (Needed) (Java)
- Java Chat Reboots (Java)
Other Threads in the Java Forum
- Previous Thread: How to include txt into jar file?
- Next Thread: I want to run my jsp page online on internet
Views: 1176 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
actuate android api apple applet application arguments array arrays automation balls binary bluetooth business chat class classes client code codesnippet collections component coordinates database defaultmethod doctype dragging draw ebook eclipse educational error event exception file fractal game givemetehcodez graphics gui helpwithhomework hql html ide image ingres input integer invokingapacheantprogrammatically j2me java javaprojects jmf jni jpanel julia linux list loop looping map method methods mobile mysql netbeans newbie number numbers object oracle parameter php print problem program programming project recursion scanner screen server set size sms socket sort sql string sun swing swt tcp test threads time transfer tree udp windows






