473,396 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with Java Debugging

Plz help me in correcting this code: It compiles but when i execute it gives error: Exception in thread "main" java.lang.NoSuchMethodError: main

Expand|Select|Wrap|Line Numbers
  1.  
  2. class Animal {
  3.       public void eat(){
  4.  
  5.       System.out.println("Animal eats");
  6.       }
  7. }
  8.  
  9. class Dog extends Animal {
  10.       public void eat(){ 
  11.           System.out.println("Dog eats");
  12.       }
  13.  
  14.  public static void main(String[] args){
  15.        Animal a = new Dog();
  16.        Dog d = new Dog();
  17.        Animal d2 = (Animal) d;
  18.        d.eat();
  19.        a.eat();
  20.        d2.eat();
  21.       }
  22. }
Mar 23 '12 #1
2 1999
r035198x
13,262 8TB
You should be running Dog class because it's the one that has the main method not the Animal class. Or better, put the main class in it's own public class and run that Tester class.
Mar 24 '12 #2
I worked on it.

Thanks.. it worked
Mar 26 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: s0hel | last post by:
Hi, I made a simple java program and I'm having a hard time debugging it. Is there a good program I can use to debug my program like in Visual Studio where I can trace my steps and make...
3
by: vishnu mahendra | last post by:
Hello every one this is vishnu can any one please tell me where can i get java debugging tools for windows.i am a newbie to java so please help me out. thank you in advance, vishnu
2
by: Simon Harvey | last post by:
Hi all, I'm hoping someone can help me with the following: I've read the microsoft documents on how to setup debugging on a remote server. I have the application set up in Visual Studio ok but...
2
by: James Bailey | last post by:
I just converted to ASP.NET 2.0 and VS2005, but I'm having major problems. I've gone through all the conversions necessary, but I can't debug my applications. I have a website designed to run as...
4
by: Jason Hunt | last post by:
I'm hoping someone can help me out with using the Visual Studio IDE for debugging. I'm working on a Windows Forms application (it's an MDI if it matters), and I'm trying to fix a bug in my...
0
by: CWeb | last post by:
Hi Guys, I got into trouble again in debugging the web service developed before. Got the error message "Unable to start debugging on the web server.", I have met this problem before and solved by...
0
by: joef | last post by:
I'm running VS.net on my PC (W2K) connected to a remote IIS server (W2K) SP4 that is not a domain controller. I've got the ASPNET and IWAM accounts in the "Impersonate a client after...
23
by: keyser_Soze | last post by:
I have MS Visual Studio 2003 on Windows XP Pro. I have IIS running on this machine and I am trying to debug some existing code which has both ASP and ASP.NET components. When I try and launch...
1
by: 848lu | last post by:
hey i really need help...i got this code....basically im suppose to make a calender that allows a user to type in month and year .... and the calander displays it on the scree using...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.