我试图通过限制它包含的模块来减小我的应用程序的大小。我已经为我的运行时使用jlink
. 但是,当我javapackager
使用--add-modules
and--limit-modules
选项和逗号分隔的一组我用于运行时的相同模块的列表运行时,它仍然坚持添加所有模块。它似乎不想尊重我给它的选择。如何获得该工具来限制它添加到我的应用程序包中的模块?
"Adding modules: [java.base, java.desktop, java.naming, java.sql, java.xml, java.logging,
java.management, java.scripting, java.compiler, java.rmi, java.activation, jdk.charsets, jdk.xml.dom,
java.datatransfer, jdk.httpserver, javafx.base, java.security.sasl, jdk.zipfs, jdk.crypto.ec,
jdk.management.agent, java.sql.rowset, javafx.swing, jdk.jsobject, jdk.sctp, java.smartcardio,
jdk.unsupported, jdk.scripting.nashorn, java.security.jgss, javafx.graphics, javafx.fxml, jdk.dynalink,
javafx.media, jdk.accessibility, jdk.security.jgss, javafx.web, java.xml.crypto, jdk.jfr, jdk.packager.services, jdk.net, javafx.controls,
java.prefs, jdk.naming.rmi, jdk.jdwp.agent, java.instrument, jdk.management,
jdk.security.auth, java.management.rmi, jdk.naming.dns, jdk.localedata] to runtime image."
outputDir = ...
modulePath = [/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/jmods]
addModules = [java.base, java.desktop, java.naming, java.sql, java.xml, java.logging, java.management, java.scripting, java.compiler, java.rmi, java.activation, jdk.charsets,
jdk.xml.dom, java.datatransfer, jdk.httpserver, javafx.base, java.security.sasl, jdk.zipfs, jdk.crypto.ec, jdk.management.agent, java.sql.rowset, javafx.swing, jdk.jsobject,
jdk.sctp, java.smartcardio, jdk.unsupported, jdk.scripting.nashorn, java.security.jgss, javafx.graphics, javafx.fxml, jdk.dynalink, javafx.media, jdk.accessibility, jdk.security.jgss, javafx.web, java.xml.crypto, jdk.jfr,
jdk.packager.services, jdk.net, javafx.controls, java.prefs, jdk.naming.rmi, jdk.jdwp.agent, java.instrument, jdk.management, jdk.security.auth, java.management.rmi, jdk.naming.dns, jdk.localedata]
limitModules = [java.base, java.desktop, java.naming, java.sql, java.xml, java.logging, java.management, java.scripting, java.compiler, java.rmi, java.activation]
这是我运行的命令,替换了一些用户名之类的内容:
/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/bin/javapackager -deploy -native image \
-name Commander -title Commander -vendor "username" \
-appclass com.username.commander.ui.AppWindow \
-srcdir /Users/username/Dropbox/coding/commander/Commander-java/packageJars \
-outdir /Users/username/Dropbox/coding/commander/Commander-java/target \
-outfile Commander \
-Bruntime=target/jre-9.0.1 -Bicon=src/main/resources/icons/commander.icns \
-BappVersion=1.0 \
-Bmac.CFBundleIdentifier=com.username.Commander \
-BmainJar=commander-0.0.1-SNAPSHOT-jar-with-dependencies.jar \
--add-modules java.base,java.desktop,java.naming,java.sql,java.xml,java.logging,java.management,java.scripting,java.compiler,java.rmi,java.activation \
--limit-modules java.base,java.desktop,java.naming,java.sql,java.xml,java.logging,java.management,java.scripting,java.compiler,java.rmi,java.activation \
-nosign -v