Adding module descriptor to existing JAR file

Gunnar Morling gunnar at
Mon Feb 6 08:41:56 UTC 2017


I'm trying to convert an existing non-modular JAR into a modular JAR.

Using jdeps, I was able to generate a descriptor for
the module-to-be. And the help text of the "jar" command discusses how
to add a compiled module descriptor to an existing JAR:

    jar --update --file foo.jar --main-class --module-version 1.0
     -C foo/ module-info.class

I'm struggling though with compiling the module descriptor. I tried
with --patch-module and also by providing the existing JAR via
--class-path (as it's not a module yet), but javac is complaining
about the exported packages from the not being found: error: package is empty or does not exist:

Is there an example somewhere that shows how to use javac for
compiling a module descriptor, given the classes from a non-module
JAR? I'm looking for a way without re-compiling that entire JAR, as I
don't think that's practical or even possible in some cases.

Thanks for any pointers,


More information about the jigsaw-dev mailing list