This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread "main" java.lang.NoSuchMethodError: main" Watch "Exception in thread "main" java.lang.NoSuchMethodError: main" New topic

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

Joop Hey

Joined: Feb 26, 2004
Posts: 1
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();

Could someone explain the exception?
Brian R. Wainwright
Ranch Hand

Joined: Aug 12, 2003
Posts: 92
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:


Mark Spritzler

Joined: Feb 05, 2001
Posts: 17271

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.

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
subject: Exception in thread "main" java.lang.NoSuchMethodError: main
It's not a secret anymore!