===============
INSPECTING JARs
===============

If you don't know the module name, you just have a JAR and you see a module-info.class file in there:
What module is this JAR?
Also works for automatic modules! (which don't have a module-info.class)

$ jar --file SOMEFILE.jar --describe-module


Notes:
- If the JAR contains a module-info.class, but it isn't at the root, this command won't work.
  A multi-release JAR (MR-JAR) might contain it in a META-INF/versions/VERSION directory instead
  (though this is rare, it's usually at the top level).
  
  Issuing the jar command above results in this message (for example, module descriptor in META-INF/versions/9/module-info.class):
  
  | releases: 9
  | No root module descriptor, specify --release
  
  Reissue the command with the appropriate --release option for your JDK:

$ jar --file SOMEFILE.jar --describe-module --release 11


- - - - - - - -


If the JAR has a module-info.class and you know the module name (see above), you can use javap on its module-info class,
which shows you the module descriptor in source-code form:

$ javap --module-path SOMEFILE.jar --module MODULENAME module-info


Notes:
- If the JAR contains a module-info.class, but it isn't at the root, this command won't work.
  A multi-release JAR (MR-JAR) might contain it in a META-INF/versions/VERSION directory instead (though this is rare).
  
  Issuing the javap command above results in this message:
  
  | Error: Cannot find module MODULENAME
  
  Use URL-style syntax to specify the exact location of the module-info.class file in the JAR:

$ javap jar:file:///absolute-path/to/SOMEFILE.jar!/META-INF/versions/9/module-info.class
$ javap jar:file:relative-path/to/it/SOMEFILE.jar!/META-INF/versions/9/module-info.class


- - - - - - - -


If you know the module name already:

$ java --module-path PATH --describe-module MODULENAME


Notes:
- Shows the same info as "jar --file --describe-module" above.
  Recommend using jar utility instead (easier/shorter command).

- The --module-path must be complete, including any dependent modules, so you may not be able to use it on a single JAR.
  Another reason to use jar utility instead, or javap.

- This one can still be useful if you have a directory of JARs, know the module name already, but are unsure which JAR contains it.
  Also useful for inspecting platform modules.  The --module-path is not needed in this case (platform modules always available).
  
$ java --describe-module MODULENAME     for example:
$ java --describe-module java.net.http
