问题描述
所有使用指南都展示了如何在单个 JAR 文件上运行 native-image
。但我相信大多数项目通常在类路径上使用多个 JAR(例如 Gradle 默认方式)。如何告诉 native-image 将它们全部捆绑到一个可执行文件中?
解决方法
您可以指定用于构建可执行文件的类路径:
-cp,-classpath,--class-path <class search path of directories and zip/jar files>: a separated list of directories,JAR archives,and ZIP archives to search for class files.
以下是有关 native-image
实用程序的各种选项的更多文档:https://www.graalvm.org/reference-manual/native-image/Options/
总而言之应该native-image -cp this.jar:that.jar -jar myjar.jar