Every time I think I understand this, I find again that I don't.
SuperclassX.java and SubclassY.java are both in C:\Java. No problem compiling SuperclassX.java, however SubclassY.java won't compile. C:\Java\SubclassY.java:4: cannot resolve symbol symbol : class SuperclassX location: class packageY.SubclassY public class SubclassY extends SuperclassX ^ I have directory C:\Java\packageY and my classpath includes it. I've tried C:\Java\javac SubclassY.java I've tried C:\Java\packageY\javac SubclassY.java
Well, I won't tell you what all I tried, but nothing works. What am I doing wrong?
My guess is that SubclassX (EDITED, I meant this to be SuperclassX, sorry) has default (or package) visibility and cannot be accessed by other classes outside the SAME default package. ------------------ WebNelly.com Java/XML Web Development Check it out! http://www.webnelly.com [This message has been edited by Kris Nelson (edited November 09, 2001).]
WebNelly.com<br />Java/XML Web Development<br />Check it out!<br /><a href="http://www.webnelly.com" target="_blank" rel="nofollow">http://www.webnelly.com</a>
The problem is that you declare SubclassY as belonging to packageY while SuperclassX does not have a package declaration making it belong to the DEFAULT package. These are your options :
put the same package declaration in SuperclassX to make it belong in packageY as well
remove the package declaration in SubclassY to make it belong to the default package as well.
If you choose the first option, you may have to compile with the -sourcepath and -d options (see the help by typing just 'javac') if your source files are in C:\Java. To avoid the hassle of having to deal with the options, just put your source files in a directory with the same name as the package they belong to. A third option: you declare the classes to belong to different packages (say packageX for SuperclassX). You must then include the statement import packageX.*; in SubclassY.java so that it can "see" SuperclassX. HTH ------------------ Junilu Lacar Sun Certified Programmer for the Java� 2 Platform [This message has been edited by JUNILU LACAR (edited November 09, 2001).]