This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Help me with Java. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help me with Java." Watch "Help me with Java." New topic
Author

Help me with Java.

Rui Sousa
Greenhorn

Joined: Sep 25, 2013
Posts: 6
Hi everyone!

I´m here again boring you (hope not)

there is the thing: i´m running this java code in comand promt but it gives me this error:

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

There is my code:
class DrumKit{

boolean topHat = true;
boolean snare = true;

void playSnare(){
System.out.println("bang bang ba-bang");
}
void playTopHat(){
System.out.println("ding ding da-ding");
}
}

class DrumKitTestDrive{
public static void main(String[] args){

DrumKit d = new DrumKit();

d.playSnare();
d.snare=false;
d.playTopHat();
if(d.snare == true){
d.playSnare();
}
}
}

thanks for your time.
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1502
    
    5

Hi Rui,

Welcome to CodeRanch!

Please, UseCodeTags. It makes reading the code much easier.

Coming to your question - the error is self explanatory.

However, I'm wondering - how are you running your code? Because, I can see that there is main method in DrumKitTestDrive class.

Are you running your code as
or

Maybe you are running as second command mentioned above - which is giving error regarding main method.

I hope this helps.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Rui Sousa
Greenhorn

Joined: Sep 25, 2013
Posts: 6
Anayonkar Shivalkar wrote:Hi Rui,

Welcome to CodeRanch!

Please, UseCodeTags. It makes reading the code much easier.

Coming to your question - the error is self explanatory.

However, I'm wondering - how are you running your code? Because, I can see that there is main method in DrumKitTestDrive class.

Are you running your code as
or

Maybe you are running as second command mentioned above - which is giving error regarding main method.

I hope this helps.



Thanks, appreciate your help, that was the issue.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help me with Java.
 
Similar Threads
Boolean question
Wrong coding
Head First Exercise Pg 43
class and testclass
Method help: how does this work?