This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android 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
Author

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

Joop Hey
Greenhorn

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();
p.add(l);

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

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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
Consider Paul's rocket mass heater.
 
subject: Exception in thread "main" java.lang.NoSuchMethodError: main
 
Similar Threads
noob needs help with path
How do I start the Java Virtual Machine
Help with First Java Code - Party.Java
Run Time error
Party.java in HeadFirst Java p. 3