It's not a secret anymore!
The moose likes Beginning Java and the fly likes package (ing) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "package (ing)" Watch "package (ing)" New topic

package (ing)

scott matzka

Joined: Jan 31, 2006
Posts: 9
I'm trying to set up a package that includes some useful things for any card game, such as a Card class, Deck class, etc. Check out the beginning of each class below. Both classes are saved in directory C:/J24work/cardGame. I am receiving compile time errors described below. There are a bunch of other errors as I'm referencing any Card object. I didn't have any problems when I had these classes in the same directory without any package listed. What could be the problem. thanks. cannot find symbol
symbol: class Card
location: class cardGame.Deck
private Card[] deck;

I have compiled like this on DOS
C:J24work/cardGame>javac (errors on this one)

-could there be something with the Classpath?
Tony Docherty

Joined: Aug 07, 2007
Posts: 2839
-could there be something with the Classpath?
Yes. You need to add the path to the package root to the classpath ie C:\J24work
scott matzka

Joined: Jan 31, 2006
Posts: 9
Just did that and got the compile to work. Thanks though. Also, I had to make sure I was in the J24work directory from the cmd line, and compile like this:

C:\J24work> javac cardGame/card.Java
C:\J24work> javac cardGame/deck.Java

now though I have a file and file that don't seem to recognize each other anymore. They are both in the same directory, which is C:\J24work\blackjack and should inherently recognize each other due to default package access. I definitely have the .; in my Classpath set so ??.

scott matzka

Joined: Jan 31, 2006
Posts: 9
One more thing. If I compile like this:

C:\J24work\blackjack>javac or

the only errors are that references to each other aren't recognized, but if I compile like this:

C:\J24work>javac blackjack/ or
C:\J24work>javac blackjack/

I get compile errors stating that package cardGame does not exist. These must all be related to classpath.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46367
I am too tired to give lots of details, I am afraid, but please search through this forum. There is about 1 question a month about compiling with package names, and if you find those questions you will get lots of useful information. Also look at these two sections of the Java Tutorials.
I agree. Here's the link:
subject: package (ing)
It's not a secret anymore!