| Author |
Head First Java problem
|
Tony Slocum
Greenhorn
Joined: Jun 27, 2008
Posts: 2
|
|
I bought my first java book. It is "head First Java" I am trying to learn the java language and this seemed like a good book for me. But I am already stuck within the first pages of the first chapter. It told me to write the source code, compile it, and then run it. I did so but cannot get it to run. The source code reads: 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... } after I compile and try to run it I get the following error: Exception in thread "main" java.lang.NoSuchMethodError: main I have no idea what it means or how to fix it. I've checked to make sure the books code and mine are the same. Any insight would be helpful. Thanks
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24045
|
|
Hi Tony, Welcome to JavaRanch! Hi, Welcome to JavaRanch! First, a bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. Initials aren't enough. You can change your display name here. Thanks! As far as your question goes: it's possible to have Java code without having a Java program that you can actually run. That's what you've got here: just some code, not a program, so this will compile, but not run. A program needs a "main()" method, which the book will teach you about soon enough. Don't worry about it, and just keep reading!
|
[Jess in Action][AskingGoodQuestions]
|
 |
Tony Slocum
Greenhorn
Joined: Jun 27, 2008
Posts: 2
|
|
|
Ahhh, okay. Thank you. I have been sitting here for almost 45 minutes trying to figure out why I couldn't get this to work. I was under the impression that it should work. The book showed a window and displayed what it would look like. Dang. Thanks for the speedy reply, now I can finally move on.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32623
|
|
|
Lots of other people have had that particular problem. Does it say anything in HFJ about "this is an incomplete application and won't run?"
|
 |
 |
|
|
subject: Head First Java problem
|
|
|