I am trying to reduce the size of my application by limiting the modules that it includes. I already did this for my runtime using jlink
. However, when I run
So it turns out that the reason why it wasn't honoring my options is because my app jar is not a Java 9 module. It's a plain old jar. In Java 9, javapackager
uses jlink
to generate the runtime and will not try to limit the number of modules because it can't determine the module dependencies. The -Bruntime
option is only for Java Web Start applications. If you want javapackager
to not use jlink
, you have to use the one in JDK 8.
I cannot turn my app jar into a module due to the complexity involved with all the 3rd party dependencies (you can see the details in this question). And I can't use JDK 8 because I need some APIs added to the Desktop module in Java 9. So, I found a workaround to get a slimmer runtime into the app using the Java 9 javapackager
:
jlink
by specifying only the modules that you need using the --add-modules
option. You can use the jdeps
command to figure out which modules are needed by all the jars in your app.javapackger
as usual..app/Contents/PlugIns/Java.runtime/Contents/Home
with those of your slimmer runtime. Do something similar for the Windows installer.