• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Java  RSS feed

 
Chris Rothgeb
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just started working out of the HFJ book, and entered the Party.java code on page 3. The information compiled and returned a class, but when I go to run the application I get the following:

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

Any assistance would be great.
Thanks
 
Chang Tzu-yu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JVM could not find the main method...

Please check the main method in your class...
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

That example is an incomplete "sketch" to show the main concepts. It won't run as it is. See the note at the bottom of page 3...
...you'll be writing real code in a moment, but for now, we just want you to get a feel for how it all fits together.

One thing that's missing from this sketch is a "main method." You'll learn about this on pages 8 and 9 with MyFirstApp.java, which is the first example that will compile and run.
[ March 27, 2008: Message edited by: marc weber ]
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my suggestion is to type the whole error line into a google search,

there are a lot of common errors (this may be #1), and you can often find the suspect cause by doing such a search,
 
Chris Rothgeb
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the input. I suspected it may not work but thought I would try to be sure. Also, I will search error messages as suggested in the future. Thanks again.
Chris
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!