title: javac: how to compile multiple classes in multiple directories?
body: <p>I'm trying to create a client-server architecture and I want use only javac to compile my code. I'd like to have these directories tree: </p>
  
  <pre><code>/Project/Server/src/Server.java
                     /ClientConnection.java
                 /bin/Server.class
                     /ClientConnection.Class
  
          /Global/src/Constants.java
                     /Packet.java
                 /bin/Constants.class
                     /Packet.Class
  
          /Client/src/(it doesn't matter at the moment)
                 /bin/(it doesn't matter at the moment)
  </code></pre>
  
  <p>I want to use the Constant and the Packet classes either in the server than in the client but with javac I'm not able to do it. I really can't understand how packages and import keyword work. For example I can't understand why the code below is wrong:</p>
  
  <p>Small Server code piece:</p>
  
  <pre><code>import Global.src.Constants;
  import Server.src.*
  
  public class Server extends ThreadPoolExecutor{
     private Iterator&lt;ClientConnection&gt; iterator;
     private NodeServer[] map;
     private ServerSocket listener;
     private ArrayList&lt;ClientConnection&gt; clients;
     private HashSet&lt;ClientConnection&gt; clientsDisconnected;
  </code></pre>
  
  <p>Commands to compile and relative errors:</p>
  
  <pre><code>javac -sourcepath ~/Documenti/Project Server.java
  
  Server.java:1: error: cannot access Constants
     import Global.src.Constants;
               ^
  bad source file: /home/francesco/Documenti/Project/Global/src/Constants.java
  file does not contain class Global.src.Constants
  Please remove or make sure it appears in the correct subdirectory of the sourcepath.
  </code></pre>
  
  <p>Can anyone help me to have the directories structure previously described? </p>
  
  <p>Thank you in advance!</p>
  
  <p>Seashell I like your solution but I don't understand how to applay it. I crated the common.jar file but I don't know how to import it. Futhermore I don't got whether I need to create a package yet. Could you give me any clarifications please?</p>