File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help me with Java.

 
Rui Sousa
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic