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:
It seems straightforward enough. Except that I get the following error message after typing java Jabberwock: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(); } }
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?
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.


Reply With Quote


Bookmarks