I lost the thread where this discussion was going on, but meanwhile left without any final conclusion.
javac finds the needed source file and complies them as well with the main source file.
I disagreed with that.
"javac -cp only finds class files. If the needed class file does not exist, it gives compiler error."
What I know: "Suppose Source A.java is using B's (public class) instance and methods so when you complile A.java, B.class must be present in order to compile A.java."
My question is if B.class does not exist in the "two" directory, and we try to compile A.java that is in the "one" directory, would it also compile B.java that is in the "two" directory. I know it is senseless question.
We must compile B.java before we can compile A.java, because javac will search for B.class and not B.java.
We can do it in one line two like:
top>javac one/A.java two/B.java
italics is my doubt and bold is what it should be!
Guide me!!
Thanks, cmbhatt
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
posted
0
would it also compile B.java that is in the "two" directory?
Well, that's what it did! I certainly did not compile it.
Chandra Bhatt
Ranch Hand
Joined: Feb 28, 2007
Posts: 1707
posted
0
Great Barry,
I did the same, and it worked. B.class automatically created in "two" directory.
But if we give classpath (-cp) with javac, then what happens.