wood burning stoves*
The moose likes IDEs, Version Control and other tools and the fly likes Main class not recognized Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Main class not recognized" Watch "Main class not recognized" New topic
Author

Main class not recognized

Kevan Ryan
Greenhorn

Joined: Feb 08, 2010
Posts: 9
Hey Javaranchers,

For some reason, the NetBeans IDE does not recognize the main class within my program. I thought that there was a way to set an object class as a 'main', but I'm not entirely sure. Is any requirement the main class needs to have, so that it is recognized?

Thanks in advance!

||
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41165
    
  45
It must have a method with this signature:

public static void main (String[] args)


Ping & DNS - my free Android networking tools app
Kevan Ryan
Greenhorn

Joined: Feb 08, 2010
Posts: 9
Yeah, that's what I figured too, but it still doesn't seem to recognize it. Here is my entire program posted, but I feel that the mistake I'm making is just a small thing that slip out of my mind.

Thanks!



Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

So how do you mean, it's not recognized? Just checking: the "main()" in the "Main" class above doesn't actually do anything at all, so if you ran it, it would immediately exit with no effect. You know that, right?


[Jess in Action][AskingGoodQuestions]
Kevan Ryan
Greenhorn

Joined: Feb 08, 2010
Posts: 9
Yeah, I realize that right now the 'main' class does nothing. But I don't know where to go from here.

Right now the NetBeans IDE won't run the program because it says that my package has no Main class. And even with the 'main class to nowhere', it still doesn't run. It's pretty frustrating, considering that my program is finished but this error is keeping me from actually running it.


EDIT: It turns out I did end up making a silly mistake - I forgot to put the other object classes inside my main class. Thanks for all who helped!
Colin Wright
Greenhorn

Joined: Apr 21, 2010
Posts: 8
It's not a main class you need it's a main method in your class, the class should have the same name as the file (but without the .java).

public static void main (String[] args) {

inside your class is needed.

But you should have one public class per java file with the same name as the source file without the extension. you can also have private and inner classes in a file but if you want multiple public classes in a package you can create more source files.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Main class not recognized
 
Similar Threads
jarring submission
Setting the classpath
Java bean in servlet
jar questions
simple main function doubt