File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help in compiling package

 
Wasim Ahmed
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
:confused
 
Jane Griscti
Ranch Hand
Posts: 3141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic