This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Head First Exercise Pg 43 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Head First Exercise Pg 43" Watch "Head First Exercise Pg 43" New topic
Author

Head First Exercise Pg 43

Tariq Ab
Greenhorn

Joined: Oct 24, 2009
Posts: 14
Hi,

I'm having a problem running this program. It compiles and everything but for some reason it doesn't run
I'm still a noob so i know it must be something silly

fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9950
    
    6

what exactly do you mean by "it doesn't run"? When you try to run it, the OS probably gives you a message telling you exactly what the problem is. That information is actually very helpful in determining the solution - in fact, it is critical.

Please post the exact and complete error message. without it, all we can do is guess at any of the dozen or so possible things it could be.


Never ascribe to malice that which can be adequately explained by stupidity.
Tariq Ab
Greenhorn

Joined: Oct 24, 2009
Posts: 14
sorry about that.

this is what i get:

main method not found in class DrumKit, please define the main method as: public static void main (String[] args )
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 530
That's the most helpful error message I think I've seen. It tells you plainly that the compiler is looking for the main() method in your class DrumKit. That's because your file is named DrumKit.java, and the compiler is expecting the class of the same name to contain the required main() method.

You could change the file name to "DrumKitTestDrive.java" or move your existing main() method to your DrumKit class and eliminate the DrumKitTestDrive class entirely, depending on your program or assignment's requirements.


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32694
    
    4
I think you ought to keep the multiple classes. That is one of the nice things about Head First; they give you the classes and a different class to run them from. It is a good ot become accustomed to using multiple classes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Head First Exercise Pg 43
 
Similar Threads
Error: Exeption in thread "main" java.lang.NoSuchMethodError: main
Method help: how does this work?
Boolean question
Wrong coding
Head First Java Beginnner's Question