Main class not recognized
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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!
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!
||
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
It must have a method with this signature:
public static void main (String[] args)
public static void main (String[] args)
Kevan Ryan
Greenhorn
Posts: 9
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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!
Thanks!
||
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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?
Kevan Ryan
Greenhorn
Posts: 9
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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!
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!
||
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
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.
| We're being followed by intergalactic spies! Quick! Take this tiny ad! The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |








