java - 错误:缺少 JavaFX 运行时组件,需要运行此应用程序(使用 Maven)
问题描述
Error: JavaFX runtime components are missing, and are required to run this application
当我尝试编译 JavaFX 应用程序时,IDEA中出现错误。我通过 maven 添加了模块。有 pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>clockAlarm</artifactId>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.5</version>
<configuration>
<mainClass>Program</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
如果我只想通过 maven 使用 JavaFX 模块而不下载 sdk 并自行设置,如何解决?
有Programm类:
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.Group;
import javafx.scene.text.Text;
public class Program extends Application {
public static void main(String[] args) {
Application.launch(args);
}
public void start(Stage stage) {
Text text = new Text("Alarm Clock");
text.setLayoutY(80);
text.setLayoutX(100);
Group group = new Group(text);
Scene scene = new Scene(group);
stage.setScene(scene);
stage.setTitle("alarmClock");
stage.setWidth(300);
stage.setHeight(250);
stage.show();
}
}
所有项目设置都设置为 13 java 版本。
解决方案
推荐阅读
- c# - 将文本(字符串值)附加到 txt 文件的每一行
- mongodb - MongoBD Compass querySrv ENODATA _mongodb._tcp.cluster0.yqxra.gcp.mongodb.net
- laravel - 如何在不使用 DB::raw 的情况下编写 Laravel 雄辩的查询,这样它就不必将 MySQL 严格模式设置为 false
- javascript - 使用 Google Apps 脚本问题将 Google 表单响应传输到 Google 表格
- php - 我无法创建登录名来登录帐户
- python - 如何捕获从 MYSQL 触发器(嵌入在另一个 py 脚本中)内部调用的 python 脚本的输出?
- python - Python asyncio 处理取消任务
- r - Stargazer 导出到 excel (xlsx)
- php - PHP子串计数函数
- lua - Lua脚本 - 按下鼠标按钮时多键,释放时停止