File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Head First Java (2nd Ed.) p. 112 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Head First Java (2nd Ed.) p. 112" Watch "Head First Java (2nd Ed.) p. 112" New topic

Head First Java (2nd Ed.) p. 112


Joined: Dec 31, 2006
Posts: 3
The instructions on page 112 are to "Drop all three classes(...) into the same directory...
my question is based on the fact that the only successful class/java-file i compiled was the one called GameHelper. What is the exact syntax and file name(s) of the other two supposed to be, i've tried many and continue to get compile errors...
the other two (saved in one .java file together, or two separate .java files) are referred to as SimpleDotCom and SimpleDotComGame.

thanks, marsooka
[ December 31, 2006: Message edited by: barclay mcdaniel ]
Bert Bates

Joined: Oct 14, 2002
Posts: 8898
Hey Barclay,

Can you tell us a little more about exactly what files you have (their exact names), what directory(ies) they are in, what compiler command you're using, and exactly what errors you're getting?



Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Davy Kelly
Ranch Hand

Joined: Jan 12, 2004
Posts: 384
i think what they are trying to say is that the 3 classes should be in the same directory e.g. C:\Program Files\Java\jdk1.5.0_03 so that you can compile and run them you only compile the SimpleDotComTestDrive file and the rest should compile automatically

then run it.

so to re-iterate, have all 3 java files in a directory typically, where the bin file is.

save all 3 files with their, here is the code:

compile "javac" this will in turn compile the rest, then run it java SimpleDotComTestDrive this should run all 3 classes as the game.

[ December 31, 2006: Message edited by: Davy Kelly ]

How simple does it have to be???
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

Yes, each (public) class should be in a separate file. When you compile them, be sure to compile in one step so all the classes are found.

>javac *.java

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2

Joined: Dec 31, 2006
Posts: 3
[ December 31, 2006: Message edited by: barclay mcdaniel ]
I agree. Here's the link:
subject: Head First Java (2nd Ed.) p. 112
It's not a secret anymore!