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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
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: 9
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: 289

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: 9
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: 289

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: 39425
    
  28
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.
tarik kaya
Greenhorn

Joined: Mar 17, 2014
Posts: 1
this one is easier than changing folder name i think;


change the code

import helpers.GameHelper;

to

import <yourpackagename>.GameHelper;

it should work
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39425
    
  28
Welcome to the Ranch

I still prefer the method of leaving out the package names and import declarations.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: This code of mine is not working, Please help.... i am studying from Head first java