我运行以下命令为 .jar 文件创建本机包:
javapackager.exe -deploy -native image -srcfiles <files> -appclass <class> -outdir out -outfile test
使用 Java 8u171/172bundles/AppName/
文件夹(包含用于启动 Java 应用程序的 .exe 和一些其他内容)包含以下 DLL 文件:
api-ms-win-core-console-l1-1-0.dll
api-ms-win-core-datetime-l1-1-0.dll
api-ms-win-core-debug-l1-1-0.dll
api-ms-win-core-errorhandling-l1-1-0.dll
api-ms-win-core-file-l1-1-0.dll
api-ms-win-core-file-l1-2-0.dll
api-ms-win-core-file-l2-1-0.dll
api-ms-win-core-handle-l1-1-0.dll
api-ms-win-core-heap-l1-1-0.dll
api-ms-win-core-interlocked-l1-1-0.dll
api-ms-win-core-libraryloader-l1-1-0.dll
api-ms-win-core-localization-l1-2-0.dll
api-ms-win-core-memory-l1-1-0.dll
api-ms-win-core-namedpipe-l1-1-0.dll
api-ms-win-core-processenvironment-l1-1-0.dll
api-ms-win-core-processthreads-l1-1-0.dll
api-ms-win-core-processthreads-l1-1-1.dll
api-ms-win-core-profile-l1-1-0.dll
api-ms-win-core-rtlsupport-l1-1-0.dll
api-ms-win-core-string-l1-1-0.dll
api-ms-win-core-synch-l1-1-0.dll
api-ms-win-core-synch-l1-2-0.dll
api-ms-win-core-sysinfo-l1-1-0.dll
api-ms-win-core-timezone-l1-1-0.dll
api-ms-win-core-util-l1-1-0.dll
api-ms-win-crt-conio-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll
api-ms-win-crt-environment-l1-1-0.dll
api-ms-win-crt-filesystem-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-locale-l1-1-0.dll
api-ms-win-crt-math-l1-1-0.dll
api-ms-win-crt-multibyte-l1-1-0.dll
api-ms-win-crt-private-l1-1-0.dll
api-ms-win-crt-process-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll
api-ms-win-crt-utility-l1-1-0.dll
msvcp140.dll
msvcr100.dll
packager.dll
ucrtbase.dll
vcruntime140.dll
Run Code Online (Sandbox Code Playgroud)
其中大部分似乎也存在于runtime/bin/
子文件夹中。
与此相反,使用 Java 8u161 运行相同的 javapackager 命令只会导致包含以下 DLL 文件(同样,除了 .exe 和其他内容之外):
msvcp140.dll
packager.dll
vcruntime140.dll
Run Code Online (Sandbox Code Playgroud)
我认为 8u161 实际上缺少 msvcr100.dll(根据这个错误),但除此之外它似乎更合理。
我真的需要api-ms-win-*
bundle 文件夹中的所有DLL 吗?请注意,它们runtime/bin/
在包含的 JRE的文件夹中仍然可用,但不知何故,我无法想象它们对于 AppName.exe 的初始执行是必要的。
我发现这个 OpenJDK 提交似乎反映了这种变化。它修复了 8u161 中提到的问题,并且添加api-ms-win-*
DLL 似乎是故意的。我仍然不相信所有这些都是必需的,尽管除了看起来很奇怪之外,我没有充分的理由。如果没有它们,应用程序似乎运行良好,但当然我不能确定在任何情况下都会是这种情况。