title: Can't compile using javac classpath with a jar file
body: <p>I'm learning how to compile by hand and I can't see what I'm doing wrong.</p>
  <p>I have a .java file named FileServlet.java which has a few imports that I have in a .jar file named servlet-api.jar. Both files are in the same directory.</p>
  <pre><code>Folder: C:\Users\User\Desktop\JTEST
      FileServlet.java
      servlet-api.jar
  </code></pre>
  <p>FileServlet.java:</p>
  <pre><code>package com.k2b;
  
  import java.io.BufferedInputStream;
  import java.io.BufferedOutputStream;
  import java.io.Closeable;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.net.URLDecoder;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  /**
   * The File servlet for serving from absolute path.
   * @author BalusC
   * @link https://balusc.omnifaces.org/2007/07/fileservlet.html
   */
  public class FileServlet extends HttpServlet {
      //MyCode
  }
  </code></pre>
  <p>I did some reading on -cp so I tried the following.
  Javac version is 13.0.1</p>
  <pre><code>javac -cp servlet-api.jar FileServlet.java
  </code></pre>
  <p>But I get:</p>
  <pre><code>FileServlet.java:21: error: cannot find symbol
  public class FileServlet extends HttpServlet {
                                   ^
    symbol: class HttpServlet
  FileServlet.java:33: error: cannot find symbol
      public void init() throws ServletException {
                                ^
    symbol:   class ServletException
    location: class FileServlet
  FileServlet.java:43: error: cannot find symbol
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
  
  etc...
  </code></pre>
  <p>What's the problem here? Shouldn't indicating the jar file in the classpath suffice? There's folders inside the .jar file does that have an effect? If so, how do I modify my classpath references?</p>
  <p>For example, the class HttpServlet is located this way inside the .jar:</p>
  <pre><code>javax
  --servlet
  ----http
  ------HttpServlet.class
  </code></pre>
  <p>As suggested, I ran the command with the -verbose flag, it outputs this:</p>
  <pre><code>[parsing started SimpleFileObject[C:\Users\User\Desktop\JTEST\FileServlet.java]]
  [parsing completed 30ms]
  [loading /modules/jdk.crypto.mscapi/module-info.class]
  [loading /modules/jdk.internal.ed/module-info.class]
  [loading /modules/java.net.http/module-info.class]
  [loading /modules/jdk.jdwp.agent/module-info.class]
  [loading /modules/java.instrument/module-info.class]
  [loading /modules/jdk.management.jfr/module-info.class]
  [loading /modules/jdk.jdeps/module-info.class]
  [loading /modules/jdk.naming.rmi/module-info.class]
  [loading /modules/jdk.jconsole/module-info.class]
  [loading /modules/java.management.rmi/module-info.class]
  [loading /modules/jdk.jlink/module-info.class]
  [loading /modules/jdk.charsets/module-info.class]
  [loading /modules/jdk.security.auth/module-info.class]
  [loading /modules/jdk.management.agent/module-info.class]
  [loading /modules/java.scripting/module-info.class]
  [loading /modules/jdk.internal.vm.compiler.management/module-info.class]
  [loading /modules/java.naming/module-info.class]
  [loading /modules/jdk.zipfs/module-info.class]
  [loading /modules/jdk.internal.opt/module-info.class]
  [loading /modules/jdk.net/module-info.class]
  [loading /modules/java.se/module-info.class]
  [loading /modules/java.datatransfer/module-info.class]
  [loading /modules/jdk.internal.vm.compiler/module-info.class]
  [loading /modules/jdk.xml.dom/module-info.class]
  [loading /modules/jdk.javadoc/module-info.class]
  [loading /modules/jdk.security.jgss/module-info.class]
  [loading /modules/jdk.rmic/module-info.class]
  [loading /modules/jdk.jartool/module-info.class]
  [loading /modules/jdk.sctp/module-info.class]
  [loading /modules/jdk.unsupported.desktop/module-info.class]
  [loading /modules/java.rmi/module-info.class]
  [loading /modules/jdk.naming.dns/module-info.class]
  [loading /modules/jdk.internal.le/module-info.class]
  [loading /modules/jdk.jsobject/module-info.class]
  [loading /modules/jdk.scripting.nashorn/module-info.class]
  [loading /modules/jdk.localedata/module-info.class]
  [loading /modules/jdk.crypto.ec/module-info.class]
  [loading /modules/jdk.jstatd/module-info.class]
  [loading /modules/java.logging/module-info.class]
  [loading /modules/jdk.jshell/module-info.class]
  [loading /modules/java.xml/module-info.class]
  [loading /modules/java.sql/module-info.class]
  [loading /modules/java.xml.crypto/module-info.class]
  [loading /modules/java.base/module-info.class]
  [loading /modules/java.transaction.xa/module-info.class]
  [loading /modules/jdk.scripting.nashorn.shell/module-info.class]
  [loading /modules/jdk.jdi/module-info.class]
  [loading /modules/java.security.jgss/module-info.class]
  [loading /modules/jdk.hotspot.agent/module-info.class]
  [loading /modules/jdk.editpad/module-info.class]
  [loading /modules/jdk.jfr/module-info.class]
  [loading /modules/jdk.internal.vm.ci/module-info.class]
  [loading /modules/java.smartcardio/module-info.class]
  [loading /modules/jdk.aot/module-info.class]
  [loading /modules/jdk.accessibility/module-info.class]
  [loading /modules/jdk.jcmd/module-info.class]
  [loading /modules/jdk.pack/module-info.class]
  [loading /modules/jdk.unsupported/module-info.class]
  [loading /modules/jdk.dynalink/module-info.class]
  [loading /modules/java.prefs/module-info.class]
  [loading /modules/java.security.sasl/module-info.class]
  [loading /modules/java.management/module-info.class]
  [loading /modules/jdk.compiler/module-info.class]
  [loading /modules/java.sql.rowset/module-info.class]
  [loading /modules/jdk.httpserver/module-info.class]
  [loading /modules/java.compiler/module-info.class]
  [loading /modules/jdk.crypto.cryptoki/module-info.class]
  [loading /modules/jdk.management/module-info.class]
  [loading /modules/jdk.attach/module-info.class]
  [loading /modules/java.desktop/module-info.class]
  [loading /modules/jdk.internal.jvmstat/module-info.class]
  [search path for source files: servlet-api.jar]
  [search path for class files: C:\Program Files\Java\jdk-13.0.1\lib\modules,servlet-api.jar]
  [loading /modules/java.base/java/io/BufferedInputStream.class]
  [loading /modules/java.base/java/io/BufferedOutputStream.class]
  [loading /modules/java.base/java/io/Closeable.class]
  [loading /modules/java.base/java/io/File.class]
  [loading /modules/java.base/java/io/FileInputStream.class]
  [loading /modules/java.base/java/io/IOException.class]
  [loading /modules/java.base/java/net/URLDecoder.class]
  FileServlet.java:21: error: cannot find symbol
  public class FileServlet extends HttpServlet {
                                   ^
    symbol: class HttpServlet
  [loading /modules/java.base/java/lang/String.class]
  FileServlet.java:33: error: cannot find symbol
      public void init() throws ServletException {
                                ^
    symbol:   class ServletException
    location: class FileServlet
  FileServlet.java:43: error: cannot find symbol
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
                           ^
    symbol:   class HttpServletRequest
    location: class FileServlet
  FileServlet.java:43: error: cannot find symbol
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
                                                       ^
    symbol:   class HttpServletResponse
    location: class FileServlet
  FileServlet.java:44: error: cannot find symbol
          throws ServletException, IOException
                 ^
    symbol:   class ServletException
    location: class FileServlet
  [loading /modules/java.base/java/lang/Deprecated.class]
  [loading /modules/java.base/java/lang/annotation/Retention.class]
  [loading /modules/java.base/java/lang/annotation/RetentionPolicy.class]
  [loading /modules/java.base/java/lang/annotation/Target.class]
  [loading /modules/java.base/java/lang/annotation/ElementType.class]
  [checking com.k2b.FileServlet]
  [loading /modules/java.base/java/io/Serializable.class]
  [loading /modules/java.base/java/lang/AutoCloseable.class]
  [loading /modules/java.base/java/lang/Exception.class]
  [loading /modules/java.base/java/lang/Throwable.class]
  FileServlet.java:53: error: cannot find symbol
              response.sendError(HttpServletResponse.SC_NOT_FOUND); // 404.
                                 ^
    symbol:   variable HttpServletResponse
    location: class FileServlet
  [loading /modules/java.base/java/lang/Object.class]
  [loading /modules/java.base/java/nio/charset/Charset.class]
  [loading /modules/java.base/java/lang/Comparable.class]
  FileServlet.java:64: error: cannot find symbol
              response.sendError(HttpServletResponse.SC_NOT_FOUND); // 404.
                                 ^
    symbol:   variable HttpServletResponse
    location: class FileServlet
  FileServlet.java:69: error: cannot find symbol
          String contentType = getServletContext().getMimeType(file.getName());
                               ^
    symbol:   method getServletContext()
    location: class FileServlet
  [loading /modules/java.base/java/lang/CharSequence.class]
  [loading /modules/java.base/java/lang/constant/Constable.class]
  [loading /modules/java.base/java/lang/constant/ConstantDesc.class]
  [loading /modules/java.base/java/lang/Byte.class]
  [loading /modules/java.base/java/lang/Character.class]
  [loading /modules/java.base/java/lang/Short.class]
  [loading /modules/java.base/java/lang/Long.class]
  [loading /modules/java.base/java/lang/Float.class]
  [loading /modules/java.base/java/lang/Integer.class]
  [loading /modules/java.base/java/lang/Double.class]
  [loading /modules/java.base/java/lang/Boolean.class]
  [loading /modules/java.base/java/lang/Void.class]
  [loading /modules/java.base/java/io/FileDescriptor.class]
  [loading /modules/java.base/java/io/OutputStream.class]
  [loading /modules/java.base/java/io/FilterInputStream.class]
  [loading /modules/java.base/java/io/InputStream.class]
  [loading /modules/java.base/java/io/FilterOutputStream.class]
  [loading /modules/java.base/java/io/Flushable.class]
  [total 324ms]
  8 errors
  </code></pre>