title: How does Javac work for multiple files, directories, classes and source?
body: <p>I'm trying to figure out how javac works with regard to stuff like sourcepath, classpath and prebuilt classes etc. I'm trying to read the documentation, but can't really make sense of it.</p>
  
  <p>I've tried to think of some sample cases below.</p>
  
  <ol>
  <li><p>If I'm compiling a single file onlyfile.java which has no dependencies, which has 2 classes A and B , and class A uses class B , does class B need to be defined/declared before A ? Or is javac smart and does multiple passes or something like that ?</p></li>
  <li><p>root.java uses another class in a file file2.java located in the same folder. If I execute javac root.java , how does javac know to search the folder for the class file and if not found , for source file instead ?</p></li>
  <li><p>How does the above work if the file2 is located in a subdirectory ?</p></li>
  </ol>
  
  <p>EDIT:
  I read somewhere that import is just a way to cut down on typing rather than "loading" anything like in python. 
  Suppose that I'm building only 1 java file which uses multiple other classes, and that these class files already exist. Without import, the a.b.c.d part of the class object already tells me where to search for the class file, then why a cp option ?</p>