This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I have class A in Package P1 and its sub-class Class B in Package P2. I am able to compile class A from P1 directory on the prompt but I am Getting erro when I compile Class B from P2 directory at the prompt. I have import statement in class B importing class A and the error message says can't find class A and gives error at import statement. How can I compile class B in package P2? am confused....! Swati
Hi Swati, Just check whether your import statement is import p1.*; or not. If you want to import only the class A from the package P1 then your import statement should be import P1.A ;. Also, please check , are you trying to access the members of class A through a reference of A class or reference of class B. Finally, do make it point to check the access modifier of the class A in package P1. Please revert in case this is still a problem. You may post your code so that we can figure out the exact problem. Ravindra Mohan.
[This message has been edited by Ravindra Mohan (edited May 24, 2001).]
use the following commands to compile from the c:\someDir prompt:
Java assumes the package names follow the directory structure. If you try to compile 'B.java' from within the 'P2' directory it expects to find the 'P1' directory referred to in the 'import' statement within the current directory. Hope that helps. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform