aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse tells me I have no main class when I clearly do Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse tells me I have no main class when I clearly do" Watch "Eclipse tells me I have no main class when I clearly do" New topic
Author

Eclipse tells me I have no main class when I clearly do

Joao Adriano
Greenhorn

Joined: May 12, 2011
Posts: 4

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?
Steve Fahlbusch
Bartender

Joined: Sep 18, 2000
Posts: 582
    
    7

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?

Joao Adriano
Greenhorn

Joined: May 12, 2011
Posts: 4
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.

Thanks!
Edit: By the way, what's a function signature?
Steve Fahlbusch
Bartender

Joined: Sep 18, 2000
Posts: 582
    
    7

I shall make it a little more obvious.

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.

Joao Adriano
Greenhorn

Joined: May 12, 2011
Posts: 4
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?
Steve Fahlbusch
Bartender

Joined: Sep 18, 2000
Posts: 582
    
    7

You are welcome --- and you did it prior to me editing my post to make more obious....

Just pass it on --- if you can help in some other post please do so.

contrats on fixing it so fast.......

have a great evening
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Steve Fahlbusch
Bartender

Joined: Sep 18, 2000
Posts: 582
    
    7

Thanks EFH.

just wanted to ply op with options == good follow up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Eclipse tells me I have no main class when I clearly do