|
| ||||||||||
| Tags: java program, java without main, java without method, main, main method, program without main, program without method |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Procedure to run Java program without main method
I have read in lots of JAVA programming book that each JAVA program should have "main method", As execution of the program starts from the "main method" of the program. And we can't ignore main method I want to know the is it possible to create & execute JAVA program code without "main method" ? Please suggest me.... Last edited by Sheena_thakkar : 26-11-2009 at 01:15 PM. |
|
#2
| |||
| |||
| Re: Procedure to run Java program without main method
Yes, It is possible to create Java program code without "main method". See below example, Try to run this program it's running successfully without "main method": Quote:
|
|
#3
| ||||
| ||||
| Re: Procedure to run Java program without main method
Hi friends, By using the method known as "System.exit(0)" within the "Static Block" we can execute Java code without "main method". See something below can help you: Program: Quote:
|
|
#4
| ||||
| ||||
| Re: Procedure to run Java program without main method
Hi, According to the my Java knowledge we are able to run the java program without the "main() method". It's done using "Static block", As it's execution is done before "main() method". So when you run the java program it will first execute the content from the static block and the execution will stop after the "System.exit() method". Please refer the below example of the static block: Code: Quote:
|
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Procedure to run Java program without main method" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| During bootup I get this error message “ Error invoking method: main (java.lang.string)” | Karsten M | Windows Software | 5 | 15-12-2010 06:18 PM |
| Explain main method in java | Angelica Maria | Software Development | 5 | 10-03-2010 12:18 PM |
| Why main method is static in java? | MKAIF | Software Development | 5 | 06-03-2010 03:20 PM |
| What is method overriding and method overloading in java | beelow | Software Development | 3 | 17-11-2009 07:20 AM |
| How to pass arguments to the main method | Wannabe | Software Development | 3 | 12-09-2009 11:51 AM |