File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes package importing problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "package importing problem" Watch "package importing problem" New topic

package importing problem

Johnson K Jose
Ranch Hand

Joined: Jul 07, 2002
Posts: 36
I have a java program called which I have saved in H:\myPack.

I compiled and kept my Balance.class file in H:\myPack.
now I have another program ( saved in H:\> )which is using program

while compileing I am geting the following error
H:\>javac package myPack does not exist
import myPack.*;
^ cannot resolve symbol
symbol : class Balance
location: class TestBalance
Balance test = new Balance("Johnosn", 1000.0);
^ cannot resolve symbol
symbol : class Balance
location: class TestBalance
Balance test = new Balance("Johnosn", 1000.0);
3 errors
but I can able to run the code if I include the Balance class inside the file.

I doubt some how my code is not able to locate the package, is this may be due to some 'CLASSPATH' setting? not able to find out!
Thanks in advance
Sridhar Srikanthan
Ranch Hand

Joined: Jan 08, 2003
Posts: 366
Hi Johnson,
It seems there is a CLASSPATH problem. IN order for a package to be found, the classpath should be till before the directory. In your example. the classpath should consist of the path till H:\
even though the .class file is in H:\mypath.
Hope this helps
Leandro Oliveira
Ranch Hand

Joined: Nov 07, 2002
Posts: 298
Yes, try setting the classpath to the H, but i think it should compile, the compiler tries to find it without the class path!!! maybe there is something wrong with your compiler!!! I tested on j2sdk 1.4, and it works, i did not set the classpath to the directory.
John Paverd
Ranch Hand

Joined: Nov 17, 2002
Posts: 115
This should help:Mastering the Java classpath

SCJP 1.4
Tom Adams
Ranch Hand

Joined: Feb 07, 2003
Posts: 56
One thing to remember is that importing stuff is all about where the class files are and that your classpath points the "root" for the packages you want to use.
Where your source code is really doesn't matter (except in some project build master's / source control nazi's head...but I'm getting off topic here).

I agree. Here's the link:
subject: package importing problem
It's not a secret anymore!