That is the only class in my program, it is a part of a chat server im trying to make.
When I compile it, eclipse gives me an error "Selection does not contain main type" and it doesn't compile and run.
Can anyone please tell me what I'm doing wrong so I can go on with the actual programming?
Thanks in advance
Non-related:Also, I have read somewhere that using try catch blocks is better than using throws, can anyone explain the difference?
In Java, just like c and c++ you can not simply make up your own function signature if someone up stream is expecting something else.
As a hint: is pbulic allowed? is void allowed? is main spelled correctly (and the correct capitalization)? does it expect to handle an exception?
Joined: May 12, 2011
Thank you for fast response!
What do you mean by somone up stream? I don't quite understand, do you mean that the main can't be public or can't return void?
The throws IOException is there because of the IO operations that have to do with the sockets.
I don't understand why you are saying as a hint, does that mean you know what's wrong? If so, please tell me, because I see no reason not to...
I've been programming in java for only 3 days, using the oracle tutorials and other online resources, i didn't take a course or anything, so i just want to understand what I'm doing wrong to improve and not make the same mistake again.
Edit: By the way, what's a function signature?
the guy upstream is the JVM calling your program through a very standard function signature -- if you dont know what that is, do some research.
it looks like you are not using the standard function signature (ie: it is not expcection an exception) and therefore it can not find your function.
Joined: May 12, 2011
THANKS FOR THE HINT I found the issue by myself thanks to your hint.\
Also thanks for letting me discover by myself, that was nice.
Will be using these forums more often.
Thank you! is there any way I can give you reputation or something?
Note to bystanders: Steve's hint about the signature of main is a good hint, but the more specific suggestion about exceptions is a red herring -- the exception declaration for a method is not part of the signature, and it's actually OK for a Java main method to declare any exceptions it likes. The missing part of main's declaration here is that it needs to be static.