【发布时间】:2020-07-02 04:29:23
【问题描述】:
问题
-
如果 linux os 上没有安装 java jdk,jar 将不会运行。
-
如果在 linux 中运行 javafx jar 会出现这样的错误
Error: Could not find or load main class application.Main Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
Afer,我做到了。成功了。
要使用终端运行 java-fx 应用程序,请按以下步骤操作:
安装openjfx(如果尚未安装):sudo apt install openjfx
列出 javafx 库位置:dpkg-query -L openjfx
输出应该是这样的:
。 /usr /usr/共享 /usr/share/doc /usr/share/doc/openjfx /usr/share/doc/openjfx/TODO.Debian /usr/share/doc/openjfx/changelog.Debian.gz /usr/share/doc/openjfx/版权 /usr/share/openjfx /usr/share/openjfx/lib /usr/share/openjfx/lib/javafx.properties /usr/share/openjfx/lib/javafx.base.jar /usr/share/openjfx/lib/javafx.controls.jar /usr/share/openjfx/lib/javafx.fxml.jar /usr/share/openjfx/lib/javafx.graphics.jar /usr/share/openjfx/lib/javafx.media.jar /usr/share/openjfx/lib/javafx.swing.jar /usr/share/openjfx/lib/javafx.web.jar
运行 jar 应用程序通过包含 javafx 路径和模块:java --module-path $PATH_TO_OPENJFX-LIB --add-modules module_1,module_2,module_3,...,module_n -jar $PATH_TO_JAR_FILE
示例:
java --module-path /usr/share/openjfx/lib --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.web,javafx.swing -jar '/home/lotfi/Documents/MyAppfolder/my_application.jar'
- 如果某些时候 java 的版本与 jar 不同。罐子不起作用。
我想为没有上述问题的 java 制作安装程序。
即使用户没有在 Linux 操作系统上安装 java jdk,它也应该可以工作。
除此之外,我想在 linux os 的搜索选项中添加应用程序。
如何制作这样的应用程序?
求救!!!
【问题讨论】:
-
.debpackages 可以包含需求列表,这意味着您应该能够使 dpkg install jre + javafx 并使用其安装后脚本创建脚本文件以使用正确的参数启动应用程序。 (虽然不能写一个完整的答案,因为我目前只从 cmake C(++) 项目创建包) -
@fabian 你能提供更多信息吗?
-
你考虑过吗,github.com/openjfx/javafx-maven-plugin你可以用launcher脚本做一个jlink版本。
-
@matt 你的答案用于 javafx。回答问题 1 和 3。
-
如果您在 Unbuntu 上安装软件时遇到问题,您应该考虑在 askubuntu.com 上提问