Hi,
I just got the book Teach Yourself Java 2 Platfrom in 21 days, Professional Reference Edition. I typed in and compiled the following code in Notepad:
code:class Jabberwock {
String color;
String sex;
boolean hungry;
void feedJabberwock() {
if (hungry == true) {
System.out.println("Yum -- a peasant!");
hungry = false;
} else
System.out.println("No, thanks -- already ate.");
}
void showAttributes() {
System.out.println("This is a " + sex + " " + color + " jabberwock.");
if (hungry == true)
System.out.println("The jabberwock is hungry.");
else
System.out.println("The jabberwock is full.");
}
public static void main (String arguments[]) {
Jabberwock j = new Jabberwock();
j.color = "orange";
j.sex = "male";
j.hungry = true;
System.out.println("Calling showAttributes ...");
j.showAttributes();
System.out.println("-----");
System.out.println("Feeding the jabberwock ...");
j.feedJabberwock();
System.out.println("-----");
System.out.println("Calling showAttributes ...");
j.showAttributes();
System.out.println("-----");
System.out.println("Feeding the jabberwock ...");
j.feedJabberwock();
}
}
It seems straightforward enough. Except that I get the following error message after typing java Jabberwock:
Exception in thread "main" java.lang.NoClassDefFoundError: Jabberwock
The code compiles without an error message with javac Jabberwock.java
Any ideas as to what's causing the message to appear?
Also, the program compiles and runs fine within JPad. I get no error message in the Interactive window. I only get the error message when I'm in the DOS command prompt.
Thanks.
P.S.
I've checked the books web site and it does not mention that the error should turn up. Much less how to fix it.