• Post Reply Bookmark Topic Watch Topic
  • New Topic

Eggs Profit Loss - Building a GUI  RSS feed

 
Michael Humphreys
Greenhorn
Posts: 23
Android Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
The continuing saga of Eggs Profit Loss. This time I am building a GUI to allow the user to input the variables. It will ask the same questions that are asked in the last step of the program build. Number of chickens, price of feed, price of eggs, etc. will be input into the GUI and then the program will run its course.

When I have the private static void createAndShowGUI(){ call I get an error message that says:

java.lang.NoSuchMethodError: main
Exception in thread "main"

This error message may be misleading me, I don't know.

Here is what the code looks like, as always any pointers would be great.


The remarked lines are a part of the program I don't want the program to run at this time.
 
Mohamed Sanaulla
Bartender
Posts: 3184
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You main method is declared as
public void main(String [] args){

The main method has to be static. So the correct version would be:

public static void main(String [] args){
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) It is always a good idea to follow standard naming conventions. Class names should be capitalized for the first character. So your class should be called Chickens instead of chickens and the file saved as Chickens.java instead of chicken.java. Also compile using javac Chicken.java and run using java Chicken.
2) Inside your createAndShowGUI(), on the last line, you are calling createAndShowGUI() which will result in infinite recursion. You need to take out that line.
 
Campbell Ritchie
Marshal
Posts: 56197
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this thread would sit better on our GUIs forum. Moving.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!