title: package <name> does not exist error
body: <p>I have the following sample code from a book in their respective files, each file having the same name as the interface or class defined in it:  </p>
  
  <p><code>Logger.java</code>  </p>
  
  <pre><code>package logging;
  
  public interface Logger
  {
     boolean connect();
     boolean disconnect();
     boolean log(String msg);
  }  
  </code></pre>
  
  <p><code>LoggerFactory.java</code>  </p>
  
  <pre><code>package logging;
  
  public abstract class LoggerFactory
  {
     public final static int CONSOLE = 0;
     public final static int FILE = 1;
  
     public static Logger newLogger(int dstType, String... dstName)
     {
        switch (dstType)
        {
           case CONSOLE: return new Console(dstName.length == 0 ? null : dstName[0]);
           case FILE   : return new File(dstName.length == 0 ? null : dstName[0]);
           default     : return null;
        }
     }
  }  
  </code></pre>
  
  <p><code>Console.java</code>  </p>
  
  <pre><code>package logging;
  
  class Console implements Logger
  {
     private String dstName;
  
     Console(String dstName)
     {
        this.dstName = dstName;
     }
  
     @Override
     public boolean connect()
     {
        return true;
     }
  
     @Override
     public boolean disconnect()
     {
        return true;
     }
  
     @Override
     public boolean log(String msg)
     {
        System.out.println(msg);
        return true;
     }
  }  
  </code></pre>
  
  <p><code>File.java</code>  </p>
  
  <pre><code>package logging;
  
  class File implements Logger
  {
     private String dstName;
  
     File(String dstName)
     {
        this.dstName = dstName;
     }
  
     @Override
     public boolean connect()
     {
        if (dstName == null)
           return false;
        System.out.println("opening file " + dstName);
        return true;
     }
  
     @Override
     public boolean disconnect()
     {
        if (dstName == null)
           return false;
        System.out.println("closing file " + dstName);
        return true;
     }
  
     @Override
     public boolean log(String msg)
     {
        if (dstName == null)
           return false;
        System.out.println("writing "+msg+" to file " + dstName);
        return true;
     }
  }  
  </code></pre>
  
  <p><code>TestLogger.java</code>  </p>
  
  <pre><code>// package logging;
  
  import logging.Logger;
  import logging.LoggerFactory;
  
  public class TestLogger
  {
     public static void main(String[] args)
     {
        Logger logger = LoggerFactory.newLogger(LoggerFactory.CONSOLE);
        if (logger.connect())
        {
           logger.log("test message #1");
           logger.disconnect();
        }
        else
           System.out.println("cannot connect to console-based logger");
        logger = LoggerFactory.newLogger(LoggerFactory.FILE, "x.txt");
        if (logger.connect())
        {
           logger.log("test message #2");
           logger.disconnect();
        }
        else
           System.out.println("cannot connect to file-based logger");
        logger = LoggerFactory.newLogger(LoggerFactory.FILE);
        if (logger.connect())
        {
           logger.log("test message #3");
           logger.disconnect();
        }
        else
           System.out.println("cannot connect to file-based logger");
     }
  }  
  </code></pre>
  
  <p>All of these files are inside a folder called <code>logger</code>. The book says that executing <code>javac TestLogger.java</code> should find and compile all the necessary class files in the <code>logger</code> directory, but I get an error   </p>
  
  <pre><code>TestLogger.java:3: error: package logging does not exist
  import logging.Logger;
                ^  
  </code></pre>
  
  <p>followed by other errors mainly related to not being able to find the <code>logging</code> package. Why isn't this program compiling? I have tried creating CLASSPATH system variable that points to the parent folder of <code>logging</code> as well as trying<br>
  <code>javac -classpath "parent_folder_of_logging" TestLogger.java</code> but nothing is working. What is wrong here and how do I fix it? </p>