Originally posted by Valentin Crettaz:
Amish,
I tried your code and it does not produce any compiler error. I've added a main method to ChildOfInnerBase so that I can run the program and everything is fine.
The output is:
x is 100
hello is 0
x is 100
Are you sure you have your classpath correct?
Originally posted by Corey McGlone:
One other thing I've noticed is that, if the parent class is in the same package as the child class, no compiler error is produced. If you move the parent to a different package, however, the error appears. Also, if you make the parent member that you're trying to access public, rather than protected, the compiler error goes away.
Can anyone explain why this is? Since the member is protected, it should be considered "part of" the child and, therefore, the local class should have access to it, right?
Thanks,
Corey
Originally posted by Valentin Crettaz:
Corey,
I have no difficulties compiling your code either. There is something weird...
I've tried both examples (Amish's and yours) with both JDK 1.3.1 and JDK 1.4 b2...
Originally posted by Valentin Crettaz:
Amish that's definitely a classpath problem. When you compile you should specify the "-classpath" switch correctly to avoid such weird things...
my hierarchy is
test
test/Inheritance/ChildOfInnerBase.java
test/InnerClasses/BaseClass.java
What I did:
1. go to InnerClasses directory
2. javac -classpath .. *.java
3. go to Inheritance directory
4. javac -classpath .. *.java
5. java -classpath .. Inheritance.ChildOfInnerBase
and everything is fine
The same for you Corey...
Originally posted by Corey McGlone:
Bah! Dastardly IDE's! :roll:
Thanks, Val.
Originally posted by Valentin Crettaz:
Amish,
when you are in any of your package the classpath should be set to the parent directory, hence the .. (note that there are 2 dots).
In the classpath you set, I can only see 1 dot.
Originally posted by Valentin Crettaz:
Well, like I said it's weird...
The "cannot resolve symbol" thing is often a classpath-related issue...
I don't know what I could add...
(Flood control what ???)
[ February 13, 2002: Message edited by: Valentin Crettaz ]
SCJP2. Please Indent your code using UBB Code
SCJP2. Please Indent your code using UBB Code
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |