I'm learning Java am having trouble running an example program.
I have two files:
GoodDog.java:
class GoodDog { private int size; 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!"); } } } GoodDogTestDrive.java:
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(); } } They are typed out exactly the way they are in the book and compile without issue. When I try to run GoodDogTestDrive I get this:
nephi-shields-mac-mini:/Developer/MyProjects/GoodDog nephishields$ java GoodDogTestDrive.class java.lang.NoClassDefFoundError: GoodDogTestDrive/class Exception in thread "main" nephi-shields-mac-mini:/Developer/MyProjects/GoodDog nephishields$ What am I doing wrong?