File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes head first java chap 5 simpledotcom 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 chap 5 simpledotcom" Watch "head first java chap 5 simpledotcom" New topic
Author

head first java chap 5 simpledotcom

justin villanueva
Greenhorn

Joined: Feb 02, 2011
Posts: 9
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~
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

justin villanueva wrote:...

Welcome to the Ranch!

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...

C:\mywork>java chap05.SimpleDotCom


"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
Mihai Lita
Ranch Hand

Joined: Jan 11, 2011
Posts: 36

Hey,
The SimpleDotCom class doesn`t have a main method. You must compile and run SimpleDoComGame file
I hope it helps
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Mihai Lita wrote:...The SimpleDotCom class doesn`t have a main method...

That might be the next problem. In that case, the error would be...

Exception in thread "main" java.lang.NoSuchMethodError: main
justin villanueva
Greenhorn

Joined: Feb 02, 2011
Posts: 9
Mihai Lita wrote:Hey,
The SimpleDotCom class doesn`t have a main method. You must compile and run SimpleDoComGame file
I hope it helps

the book doesn't have a SimpleDotComGame file, doesn't have you write one in the chapter, and isn't in the chap 5 download files.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40064
    
  28
justin villanueva wrote: . . . isn't in the chap 5 download files.
I found it here, but for some peculiar reason it appears to be in the chapter 6 folder. There is a "ReadMe" file, too, which tells you how to run it.
justin villanueva
Greenhorn

Joined: Feb 02, 2011
Posts: 9
Campbell Ritchie wrote:
justin villanueva wrote: . . . isn't in the chap 5 download files.
I found it here, but for some peculiar reason it appears to be in the chapter 6 folder. There is a "ReadMe" file, too, which tells you how to run it.

I don't see the SimpleDotComGame.java in there, all I see is DotCom.java, DotComBust.java, and GameHelper.java.

I appreciate all the help btw. I just wanna get through chap 5 before I move to chap 6.
justin villanueva
Greenhorn

Joined: Feb 02, 2011
Posts: 9
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.

Thanks for all the help
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40064
    
  28
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?
justin villanueva
Greenhorn

Joined: Feb 02, 2011
Posts: 9
Campbell Ritchie wrote:
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.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40064
    
  28
The chapter 5 program appears to be incomplete, so you would have to complete it yourself. Then you would choose which class has the main() method in.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: head first java chap 5 simpledotcom