title: Add all directory contents to jar
body: <p>I can't force <code>jar</code> to package directory <em>contents</em> (recursively) to a <code>.jar</code> file. It's little bit awkward as it sounds like a basic thing but at least I have now one more argument on why I dislike java.</p>
  
  <p>I have a <code>bin</code> directory in my project folder. That directory contains <code>.class</code> files in various folders:</p>
  
  <p><img src="https://i.stack.imgur.com/FO7iH.png" alt="image description"></p>
  
  <p>I want to create a jar file that has those files and directories in the root. The structure shall remain the same. I can do this with <code>7z</code> Seven zip command:</p>
  
  <pre><code>cd bin
  7za a -r sample3.jar *.*
  </code></pre>
  
  <p>But Java won't like that a bit. I am really surprised that function such as adding all directory contents is so well hidden.</p>
  
  <p>This is what I tried:</p>
  
  <ul>
  <li><code>jar cf sample3.jar bin/*</code> or <code>jar cf sample3.jar bin</code> creates jar that contains the <code>bin</code> directory in root, not the <strong>contained</strong> directories</li>
  <li><p>This creates jar file that only contains <code>META-INF</code>:</p>
  
  <pre><code>cd bin
  jar cf sample3.jar *.*
  </code></pre></li>
  <li><p>Same problem:</p>
  
  <pre><code>cd bin
  jar cf sample3.jar *.class
  </code></pre></li>
  </ul>
  
  <p>Is there a simple way to add all directories contents to JAR? This is what I want:</p>
  
  <p><img src="https://i.stack.imgur.com/fWSHx.png" alt="image description"></p>