• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help me with Java.

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rui Sousa
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic