Hi Alan, Thanks for the quick reply. That does the trick.
--Gunnar 2017-02-06 10:26 GMT+01:00 Alan Bateman <alan.bate...@oracle.com>: > On 06/02/2017 08:41, Gunnar Morling wrote: > >> Hi, >> >> I'm trying to convert an existing non-modular JAR into a modular JAR. >> >> Using jdeps, I was able to generate a module-info.java 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 com.foo.Main >> --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 module-info.java not being found: >> >> module-info.java:7: error: package is empty or does not exist: >> com.foo >> exports com.foo >> >> 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. >> > If the classes in the module are in the output directory then javac should > be able to compile the module-info.java. For the foo.jar example then I > would expect this should work: > > mkdir classes > (cd classes; jar xf ../foo.jar) > javac -p <modulepath> -d classes module-info.java > jar uf foo.jar -C classes module-info.class > > The recipe is similar to what one would do when compiling the classes for an > older release and then compiling the module-info.java with a separate javac > command. > > -Alan