• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Joop Hey
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading the book "Head First Java" and have difficulties with some code:
import java.awt.*;
import java.awt.event.*;
class Party {

public void buildlnvite() {
Frame f = new Frame();
Label l = new Label("Party at Tim's");
Button b = new Button("You bet");
Button c = new Button("Schoot me");
Panel p = new Panel();
p.add(l);

}
}
Could someone explain the exception?
Thanks
 
Brian R. Wainwright
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Sounds like you're trying to run your Party class without a main method. The main method is what the JVM uses to start off running a java program and every Java Program has a main method somewhere. The JVM requires it to have the following method signature:

So you might try the following:

Luck.
--BW

}
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not a Servlets question, but a Java in General (Beginner) question. I am going to move this thread to the more appropriate forum.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic