• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main"  RSS feed

 
James Skid
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to java and still learning. I am trying to execute the code below which compiles successfully, but getting the following error:

"Exception in thread "main" java.lang.NoSuchMethodError: main"

Code:




Appreciate any help, thanks
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James, welcome to the Ranch!

There are two classes in the code you posted. So, which one did you try to execute and how did you try that?
 
John M Morrison
Greenhorn
Posts: 21
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you are running the class with the main method. If you attempt to run class Dog, you will get that error. Also, make sure you have these classes in the same directory.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

Always use code tags; I added them and you can see how much better the post looks
I think I shall add to what Paul C said: since the main method is in the test drive class, you should use this instruction to run your app:-
javac DogTestDrive
 
James Skid
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, you were right - I was trying to run "Dog" class and not "DogTestDrive" class.
Thanks Campbell for the code tags - will use them in future posts.
Thanks for your help - appreciate it
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!