File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes an unbelievable question about import!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "an unbelievable question about import!!!" Watch "an unbelievable question about import!!!" New topic
Author

an unbelievable question about import!!!

Mike Lin
Ranch Hand

Joined: Oct 29, 2002
Posts: 48
at the directory of c:\m
compile file A.java

then I turn to directory c:\n to compile file Test.java

compile failed ,messages:
Test.java:12: cannot resolve symbol
symbol : constructor A ()
location: class A
A i= new A();
^
1 error
BUT ,when I change the first line of Test.java to
"import p.A;"
compile success!!!


SCJP1.4 <br />Best wishes!<br />中国人!
Serghei Jelauc
Ranch Hand

Joined: Jul 24, 2002
Posts: 128
You must save A.java in the folder with mane "p" because you indicated "package p".


SCJP 1.4 <br />SCBCD 1.3<br />SCWCD 1.4
Mike Lin
Ranch Hand

Joined: Oct 29, 2002
Posts: 48
should I always supply source code files to develper who use my libs?
Kishore Dandu
Ranch Hand

Joined: Jul 10, 2001
Posts: 1934
As long as you are providing the jar of the package you don't need to provide the source code to the other user of your classes.


Kishore
SCJP, blog
Jon Egan
Ranch Hand

Joined: Mar 24, 2004
Posts: 83
the topic seems to have changed here, mid-thread.... I have a guess as to the problem with the first post. Was it that there was another class "A" (say x.A) that was found in the classpath, and overrriding the class p.A? And, that x.A did not have a no-arg constructor?
Is this maybe why the topic changed to jars? was x.A in a jar that was in the classpath before c:\ ?
copy/pasted your code, in exactly the same directories you specified, mine won't compile either way. Except mine complains it can't find the class A, where yours seems to have a problem only with the constructor in particular.
If that's not it, I'd like to hear....
-- Jon
Mike Lin
Ranch Hand

Joined: Oct 29, 2002
Posts: 48
hi,Jon
I have set the "classpath" to c:\m
Mike Lin
Ranch Hand

Joined: Oct 29, 2002
Posts: 48
when does class-loader needs java source files?
what 's the difference between import p.* and import p.A according to code above.
Mike Lin
Ranch Hand

Joined: Oct 29, 2002
Posts: 48
I find copy source file to c:\m cannot solve the problem!!!
555555555555555
HELP!!!
"import p.A" is ok.
What wrong with " import p.*;" ???
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Beginners forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: an unbelievable question about import!!!