Error message: "Does not have a main class set"

2,951 views
Skip to first unread message

tallne...@gmail.com

unread,
Feb 8, 2016, 8:50:10 PM2/8/16
to mooc.fi
Sometimes when I go to test my code I get the error message that "Project does not have a main class". Does anyone know how I can set my class so I can test my code? Thanks!!!

Jarmo Isotalo

unread,
Feb 9, 2016, 2:40:30 AM2/9/16
to tallne...@gmail.com, mooc.fi
I suppose you are talking about running the exercise locally, to manually try the program. (The green arrow, or box with a green arrow).
NetBeans doesn't always detect correctly in which class the main method (public static void main(String[])) is defined. However, you can also run the program, by having the file containing the main method open, right-clicking somewhere in that file and selecting run. 


On Tue, Feb 9, 2016 at 3:50 AM, <tallne...@gmail.com> wrote:
Sometimes when I go to test my code I get the error message that "Project does not have a main class". Does anyone know how I can set my class so I can test my code? Thanks!!!

--
http://mooc.fi
---
You received this message because you are subscribed to the Google Groups "mooc.fi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moocfi+un...@googlegroups.com.
To post to this group, send email to moo...@googlegroups.com.
Visit this group at https://groups.google.com/group/moocfi.
To view this discussion on the web visit https://groups.google.com/d/msgid/moocfi/f1628ceb-8582-43e6-8de8-3850dede5d85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

JaeW

unread,
Feb 25, 2016, 8:49:43 PM2/25/16
to mooc.fi, tallne...@gmail.com
I had this problem, too.  Like Jamo said, you can right click on the main class and choose Run.  If you want to permanently fix it within the package, though, check out this discussion on Stack Overflow for step-by-step instructions.

herna...@gmail.com

unread,
Feb 18, 2017, 1:39:50 AM2/18/17
to mooc.fi, tallne...@gmail.com
Here there is something can help you:

Press the hammer to the left of the green arrow (run), for the program to clean & build project.
Press green arrow.
Select Main Class.

Hope it works for u.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages