title: How to inject module declaration into JAR?
body: <p>Suppose I have some library <code>lib.jar</code> for which I do not have the source code (or it is written in some non-Java language which is unaware of modules yet). <code>lib.jar</code> does not have <code>module-info.class</code> and I do not want to use it as an automatic module, so I would like to inject <code>module-info.class</code> into it.</p>
  
  <p>I first generate <code>module-info.java</code> with the following command:</p>
  
  <pre><code>jdeps --generate-module-info . lib.jar
  </code></pre>
  
  <p>Suppose this generated something like that:</p>
  
  <pre><code>module lib {
      exports package1;
      exports package2;
  }
  </code></pre>
  
  <p>Then I try to compile it but <code>javac</code> fails because the packages <code>package1</code> and <code>package2</code> do not exist:</p>
  
  <pre><code>&gt; javac module-info.java
  module-info.java:4: error: package is empty or does not exist: package1
  </code></pre>
  
  <p>Of course, I can create directories <code>package1</code> and <code>package2</code> with dummy classes in them, but is there some better approach?</p>