| Author |
K&B book code example question..
|
Mike Van
Ranch Hand
Joined: Apr 06, 2006
Posts: 83
|
|
This is the example found on page 88, typed in as it was in the book. Here's my code: class GameShape { public void displayShape() { System.out.println("displaying shape"); } } class PlayerPiece extends GameShape { public void movePiece() { System.out.println("moving game piece"); } } class TilePiece extends GameShape { public void getAdjacent() { System.out.println("getting adjacent tiles"); } } public class TestShapes { public static void main(String[] args) { PlayerPiece player = new PlayerPiece(); TilePiece tile = new TilePiece(); doShapes(player); doShapes(tile); } public static void doShapes(GameShape shape) { shape.displayShape(); } } This compiles without an issue, but when executing, I get the following error: Exception in thread "main" java.lang.NoClassDefFoundError: TestShapes Any help?
|
Mike Van
If at first you don't succeed, try, try again. Unless you really suck at it. Then, you might just want to try something else, if you dont' want to be a loser I mean.
|
 |
J Sato
Ranch Hand
Joined: Mar 30, 2006
Posts: 40
|
|
|
It looks like you need to set your classpath to include the current directory. You might skip ahead to Ch. 10 or search online for additional help.
|
 |
Mike Van
Ranch Hand
Joined: Apr 06, 2006
Posts: 83
|
|
Thanks, the below works. java -classpath . TestShapes
|
 |
 |
|
|
subject: K&B book code example question..
|
|
|