File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "an unbelievable question about import!!!" Watch "an unbelievable question about import!!!" New topic

an unbelievable question about import!!!

Mike Lin
Ranch Hand

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

then I turn to directory c:\n to compile file

compile failed ,messages: cannot resolve symbol
symbol : constructor A ()
location: class A
A i= new A();
1 error
BUT ,when I change the first line of 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 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.

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
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!!!
"import p.A" is ok.
What wrong with " import p.*;" ???
Dirk Schreckmann

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:
subject: an unbelievable question about import!!!
It's not a secret anymore!