+ 1

Is java program can run without main method?means any other way?

30th Jul 2018, 5:02 AM
mayank timbal
mayank timbal - avatar
7 Respuestas
+ 1
Why would you want that? And no, The JVM on startup looks for that. Apparently prior to Java 7 you could through the usage of static blocks but not now. No good point to do so though
30th Jul 2018, 5:17 AM
Don
Don - avatar
+ 4
no there is no other way to run without main method
30th Jul 2018, 10:45 AM
Prashil Gupta
Prashil Gupta - avatar
+ 2
no there is no other way to run without main method
30th Jul 2018, 10:45 AM
Prashil Gupta
Prashil Gupta - avatar
+ 2
before 1.5v jdk version there was a way from by executing from static block .. but after 1.5v no way...
30th Jul 2018, 2:03 PM
Priyang Bhavsar
Priyang Bhavsar - avatar
+ 2
we can compile it but can not run it. there is run static block and than main method is not found earror gives.
30th Jul 2018, 2:44 PM
darshan shah
darshan shah - avatar
+ 1
yes you can run a without main method by putting your code inside static block
15th Aug 2018, 5:15 AM
Rajesh Kumar
Rajesh Kumar - avatar
0
Yes you can run but you have to exit at the end of static block this is Upto java 1.6.but in java 7 they removed and in java8 you can use javaFX and run your code
14th Aug 2019, 3:50 AM
praveen kasojjala
praveen kasojjala - avatar