Ealrann
Ealrann

Reputation: 397

JLink: export java modules in separated files

With JLink, I'm able to build my application with a tiny JVM. For now, the build is monolithic: all the java modules are melt inside one file (which can be extracted with jimage):

jlinkImage/
└──lib/
   └──modules

Now, I'd like to make incremental builds: when I deploy my application, I would like to only upload modules that changed since the last release.

Can JLink be configured to export the different java modules in separated files?

e.g.

jlinkImage/
└──lib/
   └── moduleA
   └── moduleB
   └── moduleC

Upvotes: 3

Views: 344

Answers (1)

Ealrann
Ealrann

Reputation: 397

After a deeper look on this question:

A rough answer is no. This is not the purpose of JLink, it only serve to build a tight JRE.

However, the JRE produced by JLink can still be extended with external modules. Here a simple way to separate modules in different files:

  1. Produce a minimal JRE with jlink, e.g.:

jlink --add-modules java.base,java.xml --output minimalJre

  1. Add some module jars inside the minimalJre:
minimalJre/
└──modules/
   └── moduleA
   └── moduleB
   └── moduleC
  1. Launch it with:

bin/java -p modules/ <other args>

Upvotes: 1

Related Questions