Hello, I'm having trouble with chapter 5 of Head First Java, the SimpleDotComGame.
I tried searching but couldn't find anything so if theres another thread about the same problem and solution, I'm sorry for not finding it.
Well I get up to page 113 where we go to play the game after copying and pasting the ready back GameHelper class. So I try to compile the code and I see something weird: in the CMD window, it says java SimpleDotComGame...
No where in the chapter did we make a SimpleDotComGame file. I look in the errata and downloaded the code for Chap 5 and didn't see SimpleDotComGame file anywhere.
So I try javac SimpleDotComGame and get a file not found error so I Figure its a typo. Then I try javac SimpleDotCom:
...and it compiles fine.
Then I go to run it
So I figured I typed something in wrong and go download the files from the books site, and I get the same errors.... Thanks for any help~
It looks like your class SimpleDotCom is specified to be in the package chap05. At the top of the source file, there's probably a line...
When a class is part of a package, its qualified name becomes packageName.Classname. In this case, the qualified name is chap05.SimpleDotCom. (That's why the error message says, "wrong name: chap05/SimpleDotCom.")
But the location of chap05.SimpleDotCom is not the chap05 directory. Instead, chap05.SimpleDotCom is in your mywork directory. So one way to to run this is to change your current directory to mywork, and use the qualified class name...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
alright I have it figured out now! This is for people that have the book and are working on the SimpleDotCom game and are having the same trouble.
On Page 110 when they say "The Game's main() method, the seem to have made a mistake and didn't mention that the chunk of code is supposed to be the SimpleDotComGame.java and on the download page, the main method is in a file called Game.java.
You have to put the main method on page 110 between
In the end you'll have the SimpleDotCom.java, the SimpleDotComGame.java, and GameHelper.java.
justin villanueva wrote: . . . I don't see the SimpleDotComGame.java in there, all I see is DotCom.java, DotComBust.java, and GameHelper.java. . . ..
Did you read the ReadMe file?
Yeah I did, I fixed the problem. But chap6 is for a somewhat different program (more of an expanded version of the chap 5 program) What I wanted was to get the chap 5 program working correctly before I move to chap 6.