Using legacy jar files with jlink
Thomas Brand
tom at trellis.ch
Thu Nov 16 23:03:37 UTC 2017
Hi List,
this is my first post here, I hope this is the right place to ask a
question about how to use jlink.
For a given scenario with modules a and b, a using methods of b, following
instructions I managed to create a runnable image that can be called (from
inside exploded image) like
$ ./bin/java a.A
A.main() called
B() called
string from B:test()
this works nicely, also both modules are shown with
$ ./bin/java --list-modules
a
b
java.base at 10-internal
My question is if it's possible to create that image if module b would be
a legacy jar with just the .class files in it. I understand it's possible
to auto-generate the module-info.java for this legacy b.jar.
I was thinking to be smart and just compile the generated module-info.java
for b.jar and then put it to the legacy b.jar or put the module-info.class
to the classpath in order to make it modular and then use for the jlink
step.
However that doesn't work:
$JAVAC -d compile_out src/modb/module-info.java
src/modb/module-info.java:2: error: package is empty or does not exist: b
exports b;
^
1 error
How can a legacy jar file without access to source files be used as a
module, is it possible at all? The idea is to use legacy jar files in
conjunction with jlink to be used in self-contained runtime images.
Thanks for suggestions,
best regards
Thomas Brand
More information about the jigsaw-dev
mailing list