Let's say I am developing a modular application consisting of 2 modules: com.spacey.explorerwhich depends on the module com.spacey.rocket. I have their modular JAR files in some bindirectory.
And I want to prepare a lightweight JRE to run. Therefore, obviously, I am using the jlink tool :
$ jlink --module-path /opt/jdk-9/jmods:../bin --add-modules com.spacey.explorer --output ~/custom-jre3
Now, when I list the modules in my JRE, I get the following:
$ java --list-modules
com.spacey.explorer
com.spacey.rocket
java.base@9
That is, my application modules are combined in a JRE. But if I wanted to create a JRE that has only JDK-created modules sufficient to run my application and so that my application modules are separate, I should know that my JDK is dependencies (this is easy in the example java.base) and specify them explicitly:
$ jlink --module-path /opt/jdk-9/jmods --add-modules java.base --output ~/custom-jre3
Is there a way to make jlink do this for me? Or some tool that will define these JDK dependencies for me?
source
share