title: Compiling module-info.java throws error: module not found
body: <p>I'm converting a simple application to java modules. I also need to make this application self contained with it's own custom JRE.  My application relies on multiple existing library jars that I am also converting to modular jars. To build a custom JRE I know that all code must be in modules. (You can't reference non-modular jars.  I found that out the hard way).</p>
  
  <p>The problem is when I'm compiling the modules-info.java for one of the library jars that depends on another library jar (that I have already converted to modular).  It returns "error: module not found:jersey.core"</p>
  
  <p>I've already updated one of the library jars by manually creating the module-info.java, compiling it and then updating the existing jar.</p>
  
  <p>1). The file I created.</p>
  
  <pre><code>module jersey.core {
      exports com.sun.jersey.api.provider.jaxb;
      exports com.sun.jersey.api.representation;
      exports com.sun.jersey.api.uri;
      exports com.sun.jersey.core.header;
      exports com.sun.jersey.core.header.reader;
      exports com.sun.jersey.core.impl.provider.entity;
      exports com.sun.jersey.core.impl.provider.header;
      exports com.sun.jersey.core.impl.provider.xml;
      exports com.sun.jersey.core.osgi;
      exports com.sun.jersey.core.provider;
      exports com.sun.jersey.core.provider.jaxb;
      exports com.sun.jersey.core.reflection;
      exports com.sun.jersey.core.spi.component;
      exports com.sun.jersey.core.spi.component.ioc;
      exports com.sun.jersey.core.spi.factory;
      exports com.sun.jersey.core.spi.scanning;
      exports com.sun.jersey.core.spi.scanning.uri;
      exports com.sun.jersey.core.util;
      exports com.sun.jersey.impl;
      exports com.sun.jersey.localization;
      exports com.sun.jersey.spi;
      exports com.sun.jersey.spi.inject;
      exports com.sun.jersey.spi.service;
      exports javax.ws.rs;
      exports javax.ws.rs.core;
      exports javax.ws.rs.ext;
  
      requires java.base;
      requires java.desktop;
      requires java.logging;
      requires java.xml;
  }
  </code></pre>
  
  <p>2). Compiling</p>
  
  <pre><code>"%JDK11_HOME%/bin/javac" --patch-module jersey.core=../originaljars/jersey-core-1.13.jar module-info.java
  </code></pre>
  
  <p>3). Updating the jar</p>
  
  <pre><code>"%JDK11_HOME%/bin/jar" uf ../modules/jersey-core-1.13.jar -C jersey.core module-info.class
  </code></pre>
  
  <p>This was successful.</p>
  
  <hr>
  
  <p>At first I tried creating the jersey.client module-info.java without a "depends on jersey.core".  Again, went through the same process of compiling and updating the jar but when I added the jar to my project Eclipse displayed the following error in MyTester.java.</p>
  
  <pre><code>The type javax.ws.rs.core.MediaType cannot be resolved. It is indirectly referenced from required .class files  MyTester.java   
  </code></pre>
  
  <p>This was thrown for a line where a WebResource object (comes from jersey.client) calls method webResource.type("application/json") which return a MediaType.</p>
  
  <p>javax.ws.rs.core.MediaType comes from jersey.core.  So that lead me to believe jersey.client needs to require jersey.core.</p>
  
  <p>I then decided to update the module-info.java for jersey.client<br>
  I added a requires jersey.core.</p>
  
  <pre><code>module jersey.client {
      exports com.sun.jersey.api.client;
      exports com.sun.jersey.api.client.async;
      exports com.sun.jersey.api.client.config;
      exports com.sun.jersey.api.client.filter;
      exports com.sun.jersey.client.impl;
      exports com.sun.jersey.client.impl.async;
      exports com.sun.jersey.client.osgi;
      exports com.sun.jersey.client.proxy;
      exports com.sun.jersey.client.urlconnection;
      exports com.sun.ws.rs.ext;
  
      requires java.base;
      requires java.logging;
      requires jersey.core;
  }
  </code></pre>
  
  <p>But when I try to compile this, I get the following error.</p>
  
  <pre><code>"%JDK11_HOME%/bin/javac" --patch-module jersey.client=../originaljars/jersey-client-1.13.jar module-info.java
  module-info.java:15: error: module not found: jersey.core
  requires jersey.core;
                     ^
  1 error
  </code></pre>
  
  <p>Figured, the error was literally telling me it can't find the module, so I needed to tell it where my modules were located.</p>
  
  <pre><code> "%JDK11_HOME%/bin/javac" --patch-module jersey.client=../originaljars/jersey-client-1.13.jar module-info.java -p ../modules
  module-info.java:15: error: module not found: jersey.core
  requires jersey.core;
                     ^
  1 error
  </code></pre>
  
  <p>And then thought maybe I need to also add the module explicitly.  But that also didn't work.</p>
  
  <pre><code>"%JDK11_HOME%/bin/javac" --patch-module jersey.client=../originaljars/jersey-client-1.13.jar module-info.java -p ../modules --add-modules jersey.core
   module-info.java:15: error: module not found: jersey.core
   requires jersey.core;
                     ^
   1 error
  </code></pre>
  
  <p>I'm very new to Java Modules so undoubtedly I'm doing something stupid.  Apologies in advance :(</p>