This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Party.java in HeadFirst Java p. 3  RSS feed

 
Russell Anderson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Edmund Castermund
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • 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
 
Campbell Ritchie
Marshal
Posts: 55722
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Party with a lower-case p?

You can get away with that error on Windows.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!