| Author |
package problems
|
marilyn murphy
Ranch Hand
Joined: Aug 28, 2001
Posts: 83
|
|
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? 
|
 |
Kris Nelson
Ranch Hand
Joined: Nov 04, 2001
Posts: 35
|
|
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>
|
 |
marilyn murphy
Ranch Hand
Joined: Aug 28, 2001
Posts: 83
|
|
|
There is no SubclassX. SuperclassX is public.
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4115
|
|
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).]
|
Junilu - [How to Ask Questions] [How to Answer Questions] [MiH]
|
 |
marilyn murphy
Ranch Hand
Joined: Aug 28, 2001
Posts: 83
|
|
I thought if I put it in the default package I would not have to import it.
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4115
|
|
Originally posted by marilyn murphy: I thought if I put it in the default package I would not have to import it.
If you put it in the same package, you won't have to import it. ------------------ Junilu Lacar Sun Certified Programmer for the Java� 2 Platform
|
 |
marilyn murphy
Ranch Hand
Joined: Aug 28, 2001
Posts: 83
|
|
Is there any way to import the default package?
|
 |
 |
|
|
subject: package problems
|
|
|