aspose file tools
The moose likes Beginning Java and the fly likes This code of mine is not working, Please help.... i am studying from Head first java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "This code of mine is not working, Please help.... i am studying from Head first java" Watch "This code of mine is not working, Please help.... i am studying from Head first java" New topic
Author

This code of mine is not working, Please help.... i am studying from Head first java

Mike Kris
Greenhorn

Joined: Jun 08, 2009
Posts: 7
1. This works well for me...



2. This works well for me...




3. This works well for me...




4. This is giving me an error.....



I get the following error when i compile the Game class
D:\Java>javac Game.java
Game.java:5: package helpers does not exist
import helpers.GameHelper;
^
Game.java:12: cannot access GameHelper
bad class file: .\GameHelper.class
class file contains wrong class: chap05.GameHelper
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
GameHelper helper = new GameHelper();
^
2 errors



Thanks to all in advance,

Mike

Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 283

D:\Java>javac Game.java
Game.java:5: package helpers does not exist
import helpers.GameHelper;
^
Game.java:12: cannot access GameHelper
bad class file: .\GameHelper.class
class file contains wrong class: chap05.GameHelper
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
GameHelper helper = new GameHelper();
^
2 errors



According to the error which is showing GameHelper is in the package chap05, while importing you imported from helpers.GameHelper


-Chiru
Mike Kris
Greenhorn

Joined: Jun 08, 2009
Posts: 7
Chap 05......!!!

i am sorry to say, i am very novice and i didn't understand that..... Kindly help me by giving more details or how to fix it please.

Thanks,
Mike
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 283

GameHelper.java is in the folder chap05
rename that chap05 folder in D: to helpers
then try to compile
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Better to copy the code from the book (though some of it has misprints in), and leave out the package declarations at this stage. They are in the downloaded code to separate the files into folders. You would also miss out most of the "import"s.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: This code of mine is not working, Please help.... i am studying from Head first java
 
Similar Threads
While working from Head first java, I came across this problem... Please help
Hi All, While working with Head first java, I got into a problem, please help me to solve this.....
HFJ 2nd - Problem with SimpleDotCom
HeadFirstJava - SimpleDotCom
getting exception in thread "main" java.lang.NoSuchMethodError: main error message