在 Intellij 中使用 Maven 和 JavaFX (2019.1)。我一直在关注这个教程。
我有一个不断发生的奇怪错误 - 每次我继续运行插件时javafx:run,它都会失败,并给出以下错误:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized option: --module-path
Run Code Online (Sandbox Code Playgroud)
但是,当我将可执行文件放入javafx-maven-plugin( <executable>"C:\Program Files\Java\jdk-12.0.1\bin\java.exe"</executable>) 中时,它就可以工作。我在 Windows 上,并已将JAVA_HOME系统环境变量设置为C:\Program Files\Java\jdk-12.0.1安装 JDK 的位置。
这是一个奇怪的问题,虽然并不重要,但很高兴知道答案。
pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>uk.co.harveyellis</groupId>
<artifactId>HelloFX</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.2</version>
</dependency>
</dependencies> …Run Code Online (Sandbox Code Playgroud)