2 Replies Latest reply: Oct 28, 2006 1:15 PM by 807598 RSS

    java.lang.NoSuchMethodError: main

    807598
      I have this code taken from one of the java books. It compiles fine but when i run it, it throws a java.lang.NoSuchMethodError: main.
      what am i doing wrong? All java files are in directory: c:\CodeJava
      Thanks for the help.

      class GoodDog {

           private int size; //instance variable private
           public int getSize() {
                return size;
           }
           public void setSize(int s) {
                size = s;
           }
           void bark() {
                if (size > 60) {          
                     System.out.println("wooof! wooof!");
                } else if (size > 14) {
                     System.out.println("ruff! ruff!");
                } else {
                     System.out.println("yip! yip!");
                }
           }
      }

      class GoodDogTestDrive {

           public static void main(String[] args) {

                GoodDog one = new GoodDog();
                one.setSize(70);
                GoodDog two = new GoodDog();
                two.setSize(8);
                System.out.println("Dog one: " + one.getSize());
                System.out.println("Dog two: " + two.getSize());
                one.bark();
                two.bark();
           }

      }