创建 Fat Jars:mods 文件夹是什么?

Creating Fat Jars: What is the mods folder?

我刚刚:

https://openjfx.io/openjfx-docs/#modular

尝试创建一个 jar 我可以 运行 在其他系统上(没有 javafx 库,而对于非开发外行用户来说会发生这种情况)并且他们告诉我使用这个:

dir /s /b src\*.java > sources.txt & javac --module-path %PATH_TO_FX% -d mods/hellofx @sources.txt & del sources.txt

模组是什么/ 那应该在哪里?他们在谈论 out/ 吗?

您链接的文档指的是这个sample

如果您克隆示例,并按照有关如何编译和 运行 项目的说明进行操作,则第一个命令可以分为三个部分:

dir /s /b src\*.java > sources.txt & \
javac --module-path %PATH_TO_FX% -d mods/hellofx @sources.txt & \
del sources.txt

第一部分只是获取 src 路径中的所有 Java 文件并将其添加到 sources.txt 文件:

C:\path\to\hellofx\src\module-info.java
C:\path\to\hellofx\src\hellofx\HelloFX.java

第二部分调用javac命令(见reference)编译sources.txt的内容,添加需要的--module-path选项包含JavaFX 模块,并添加输出或 destination -d option:

-d directory

Sets the destination directory for class files. If a class is part of a package, then javac puts the class file in a subdirectory that reflects the package name and creates directories as needed.

这意味着我们要将hellofx.HelloFX.java编译到目录mods/hellofx中,导致:

C:\path\to\hellofx\mods\hellofx\module-info.class
C:\path\to\hellofx\mods\hellofx\hellofx\HelloFX.class

第三步将只删除 sources.txt 文件。

现在您可以 运行 您的模块:

java --module-path "%PATH_TO_FX%;mods" -m hellofx/hellofx.HelloFX

当然,您可以为输出指定任何目录,因此您可以将其更改为 outbuild,但请确保在其余部分中相应地修改它说明。