I wrote two programs with the same classname and saved them in different directories: (1)current-directory/p1-->A.java
My question is that how to use the 2 classes in the program "P.java"? current-directory-->P.java
I tried many ways and I got the error messages like: "cannot resolve symbol" or "reference to A is ambiguous" or "p1.A is already defined in a single-type import". What did I miss? Please help, thanks a lot.
If you use fully qualified classnames (which you have to), you don't need the import statements. Try removing them. Did that help?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Thanks for all your replies. I set "classpath=.", remove the first two import lines in P.java.
And I STILL got the following error messages:
I tried to use javac -classpath" and got the same error messages. Why? I thought I understood what the package is and how to use it, but now I'm confused! [ November 13, 2002: Message edited by: Claire Yang ]
Maybe it is wrong, but you need to write the CLASSPATH in upper case letters. So please set in your environment the CLASSPATH=.; If you do this, then you don't need javac -classpath, you simply need javac.
Ron, thanks a lot for testing my programs. I finally found the "suspect" that caused all these problems. For testing the programs, I wrote another file "p1.java" with classname P1: ( p1.java is in the same directory of P.java)
"p1.java" can run completely but cause "P.java" compile error. If I changed "p1.java" to "P1.java", then each program runs fine. Since "p" & "P" are not the same to java, how come "p1.java" will affect "P.java"? Could you explain that to me? Or I still miss something? But I'm sure for one thing: not to use the ambiguous filename & classname to test programs! [ November 14, 2002: Message edited by: Claire Yang ]