title: JarFile#entries do not show "META-INF" as a JarEntry when creating jar with JarOutputStream
body: <p>As per the link : <a href="https://stackoverflow.com/a/1281295/1794012">https://stackoverflow.com/a/1281295/1794012</a></p>
  
  <p>I followed the instructions and created a jar file, the input directory where the source files for creating the jar is as follows,</p>
  
  <ul>
  <li>so  (directory)</li>
  <li>so/some.txt (file)</li>
  </ul>
  
  <p>when i am traversing through JarFile#entries method it is printing the following,</p>
  
  <h2>JarFile#entries output when jar created via JarOutputStream</h2>
  
  <blockquote>
    <p>META-INF/MANIFEST.MF<br>
    D:/so/<br>
    D:/so/some.txt  </p>
  </blockquote>
  
  <p>but i created the jar file using jar tool</p>
  
  <h3>Created jar using simple jar tool</h3>
  
  <blockquote>
    <p>jar -cvf so_commond.jar so so/some.txt<br>
    <strong>added manifest</strong><br>
    <strong>adding: so/(in = 0) (out= 0)(stored 0%)</strong><br>
    <strong>adding: so/some.txt(in = 7) (out= 9)(deflated -28%)</strong></p>
  </blockquote>
  
  <p>Now i use JarFile#entries to iterate the entries, the following is the output</p>
  
  <h2>JarFile#entries output when jar is created by jar tool</h2>
  
  <blockquote>
    <p><strong>META-INF/</strong>    (this is not there when jar created by JarOutputStream)<br>
    META-INF/MANIFEST.MF<br>
    so/<br>
    so/some.txt</p>
  </blockquote>
  
  <p>Could you please explain why the jar entry META-INF is shown only when jar is created by jar tool and does not shown when jar is created by JarOutputStream?</p>
  
  <p>Code:</p>
  
  <pre><code>public static void main(String[] args){
    run();
      for(Enumeration&lt;JarEntry&gt; e = jf.entries(); e.hasMoreElements();){
                         System.out.println(e.nextElement().getName());
          }
   }
  
   public static void run() throws IOException
      {
          Manifest manifest = new Manifest();
          manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
          JarOutputStream target = new JarOutputStream(new FileOutputStream("D:\\so.jar"),
                    manifest);
          add(new File("D:\\so"), target);
          target.close();
      }
  
      private static void add(File source, JarOutputStream target) throws IOException
      {
          BufferedInputStream in = null;
          try
          {
              if (source.isDirectory())
              {
                  String name = source.getPath().replace("\\", "/");
                  if (!name.isEmpty())
                  {
                      if (!name.endsWith("/"))
                          name += "/";
                      JarEntry entry = new JarEntry(name);
                      entry.setTime(source.lastModified());
                      target.putNextEntry(entry);
                      target.closeEntry();
                  }
                  for (File nestedFile: source.listFiles())
                      add(nestedFile, target);
                  return;
              }
  
              JarEntry entry = new JarEntry(source.getPath().replace("\\", "/"));
              entry.setTime(source.lastModified());
              target.putNextEntry(entry);
              in = new BufferedInputStream(new FileInputStream(source));
  
              byte[] buffer = new byte[1024];
              while (true)
              {
                  int count = in.read(buffer);
                  if (count == -1)
                      break;
                  target.write(buffer, 0, count);
              }
              target.closeEntry();
          }
          finally
          {
              if (in != null)
                  in.close();
          }
      }
  </code></pre>