• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Party.java in HeadFirst Java p. 3

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What am I doing wrong with this code from HeadFirst?

C:\AllMyFiles\Java\HeadFirst>type party.java
import java.awt.*;
import java.awt.event.*;
class Party {
public void buildInvite(){
Frame f = new Frame();
Label l = new Label("Party at Tim's");
Button b = new Button("You bet");
Button c = new Button("Shoot me");
Panel p = new Panel();
p.add(l);
} //more code here
}

C:\AllMyFiles\Java\HeadFirst>javac party.java

C:\AllMyFiles\Java\HeadFirst>java Party
Exception in thread "main" java.lang.NoSuchMethodError: main


Thanks,
Russ
 
Russell Anderson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nevermind. As I read further it says, "this is not meant to be a tutorial... you'll be writing real code in a moment" So I guess that means that I wasn't suppose to actually follow that exercise. And I guess it doesn't work because it doesn't have a main ... plus maybe other reasons.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one thing I noticed is that when you compile, "party" is spelled with a lower case p, and when you run, it's upper.
jason
 
Marshal
Posts: 82459
594
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Party with a lower-case p?

You can get away with that error on Windows.
 
reply
    Bookmark Topic Watch Topic
  • New Topic