+ 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
9 Respostas
+ 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)
+ 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).
+ 3
at least now i can say.....
welcome bro
+ 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!
+ 2
@neutronstar welcome (gender=="male"?bro:sis)
+ 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");
}
}
+ 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
+ 1
@Chirag,
Thank you for marking my answer as best : )
+ 1
@Chirag,
bro