title: Differences between classpath and sourcepath options of javac
body: <p>I read the Sun documentation and a lot of posts on Stack Overflow, but I'm still confused about the differences between the Java compiler options <code>-cp</code> and <code>-sourcepath</code>.  </p>
  
  <p>Let say I have this directory structure:</p>
  
  <pre><code>c:\Java\project1\src (where the Java source files are)  
  c:\Java\project1\bin (where the Java class files will be or already are)  
  </code></pre>
  
  <p>Let's also say I have a source file <code>MainClass.java</code> in a package <code>com.mypackage</code>, and that the directory structure is ok in the source folder.</p>
  
  <p>I'm in the <em>project1</em> directory and run:</p>
  
  <pre><code>javac -d bin -sourcepath src src/com/mypackage/MainClass.java  
  </code></pre>
  
  <p>or</p>
  
  <pre><code>javac -d bin -classpath src src/com/mypackage/MainClass.java  
  </code></pre>
  
  <p>and I obtain the same result. In verbose mode, the search path for source files is <code>src</code> in both cases.  </p>
  
  <p>It would be great if anybody could help me figure out the specifics of these options.</p>