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 Need Help in compiling package 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 "Need Help in compiling package" Watch "Need Help in compiling package" New topic

Need Help in compiling package

Wasim Ahmed
Ranch Hand

Joined: Jan 31, 2001
Posts: 90
Anyone tried to compile KHM Book ex #4.8. I am getting compiling error in package B "package A not found" but it is in same directory. I am using JDK 1.3 and jcreator. Any suggestion
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi Wasim,
I don't have a copy of the code but if by 'it is in the same directory' you mean the compiled class file is in the same directory as the class marked package B you will get a compile error.
If you have two source files, one marked 'package A;' and another marked 'package B' your directory set up should be

You then need to compile from the 'root' directory using

Java expects the package naming to follow the directory structure. 'package A' instructs the compiler to look for the source file in the 'A' subdirectory. 'package B' instructs the compiler to look for the source file in the 'B' subdirectory. It searches for the subdirectories in the current directory.
Hope that helps.
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform

Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
I agree. Here's the link:
subject: Need Help in compiling package
jQuery in Action, 3rd edition