title: Compiling java with classpath doesn't find all jar files
body: <p>I have a lib folder with many .jar files and one of the files I have is mail.jar (for javax.mail)</p>
  
  <p>When I compile my source code, I use</p>
  
  <pre><code>javac -cp .:../lib/ server/MyFile.java
  </code></pre>
  
  <p>And then I get a bunch of errors</p>
  
  <pre><code>server/MyFile.java:22: error: package javax.mail.internet does not exist
  import javax.mail.internet.InternetAddress;
                            ^
  server/MyFile.java:23: error: package javax.mail.internet does not exist
  import javax.mail.internet.MimeMessage;
                            ^
  server/MyFile.java:24: error: package javax.mail does not exist
  import javax.mail.Authenticator;
                   ^
  etc
  etc
  </code></pre>
  
  <p>However javax.mail should be inside (via mail.jar). I also have activation.jar inside of the lib folder. Note that this mail.jar file I just downloaded today from sun website. It is recent.</p>
  
  <p>What could be wrong?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I have added all the jar files manually on the classpath, and it compiles fine. However now when I run MyFile.java, using this command</p>
  
  <pre><code>java server.MyFile
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code> Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Authenticator
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
      at java.lang.Class.getMethod0(Class.java:2685)
      at java.lang.Class.getMethod(Class.java:1620)
      at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:492)
      at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:484)
  Caused by: java.lang.ClassNotFoundException: javax.mail.Authenticator
      at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      ... 6 more
  </code></pre>