+ 8

Main-less method in java!!!!!!!!!!

i hv created a java code which does not have a main method........ its not showing a typical sololearn error but something else.....can anyone explain what it is ???? https://code.sololearn.com/c7tp6w5Bqdzw/?ref=app

15th Jun 2017, 3:56 AM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
9 Answers
+ 4
It's not a compiler error. When you tried to run your program, JRE searched for the main method, it could not find one so it dumped the usage example of java.exe in the console window. If you have JRE or JDK installed on your machine then open a command prompt in windows or terminal window in Linux/macOS and type java.exe (on windows or appropiate executable binary file) and press enter, it will dump out how to use java.exe listing out various options that can be used to launch an application. Sololearn has done bit of customization at their end, hence you are seeing their name in the output (console window)
16th Jun 2017, 6:20 PM
NeutronStar
NeutronStar - avatar
+ 3
That's pretty cool. It looks likes a bunch of warnings from the playground compiler. I don't think it's actually trying to run without the main method, since if I add an SIB it won't run. (It could have noticed there is no main before running ie: on compilation).
15th Jun 2017, 4:08 AM
Rrestoring faith
Rrestoring faith - avatar
+ 3
at least now i can say..... welcome bro
17th Jun 2017, 12:39 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 2
It's a compiler error indicating that the minimum required arguments are missing. I.E. you don't have a main method so it won't compile!
15th Jun 2017, 4:09 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
@neutronstar welcome (gender=="male"?bro:sis)
17th Jun 2017, 12:34 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 1
well thats not possible now but upto java 6 we had the possibility to create a code without main using static block like this so from java 7 it isnt possible public class test { static { System.out.println("Hello world"); } }
15th Jun 2017, 5:13 AM
Suhail Pappu
Suhail Pappu - avatar
+ 1
upto 1.5 version without main method you can execute your program. but after 1.6 version without main method you can't execute any progress. main method required
15th Jun 2017, 3:22 PM
meherDev
meherDev - avatar
+ 1
@Chirag, Thank you for marking my answer as best : )
17th Jun 2017, 11:55 AM
NeutronStar
NeutronStar - avatar
+ 1
@Chirag, bro
17th Jun 2017, 12:36 PM
NeutronStar
NeutronStar - avatar