This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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: 17276

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 - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Exception in thread "main" java.lang.NoSuchMethodError: main
jQuery in Action, 3rd edition