Using Maven and JavaFX in Intellij (2019.1). I have been following this tutorial.
I have a curious error that keeps occurring - every time I keep running the javafx:run
plugin, it fails, giving this error:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized option: --module-path
However, when I put the executable in the javafx-maven-plugin
(<executable>"C:\Program Files\Java\jdk-12.0.1\bin\java.exe"</executable>
) it works. I am on Windows and have set the JAVA_HOME
system environment variable to C:\Program Files\Java\jdk-12.0.1
which is where the JDK is installed.
This is a curious issue that is not critical, but would be nice to know the answer to.
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>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>12</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.2</version>
<configuration>
<mainClass>uk.co.harveyellis.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
Other pictures:
C:\Rtools\bin
C:\Program Files\Microsoft MPI\Bin\
C:\Python37\Scripts\
C:\Python37\
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\WINDOWS\System32\OpenSSH\
C:\Program Files\Java\jdk-12.0.1\bin
C:\Program Files\apache-maven-3.6.1\bin
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
C:\ProgramData\chocolatey\bin
C:\Program Files (x86)\Brackets\command
C:\Program Files\Git\cmd
C:\Program Files\dotnet\
C:\Program Files\Microsoft SQL Server\130\Tools\Binn\
C:\Program Files\PuTTY\
C:\Program Files\nodejs\
C:\Program Files\Gradle\gradle-5.4\bin
Note also that C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.1\bin
is in user path.
I've been experiencing similar pains with setting up a JavaFX project with Maven. That command requires a newer version of the JDK and the issue at hand is that Maven will actually ignore your system's JAVA_HOME
and JDK_HOME
variables, as well as your IDE settings.
You can check which version of Java that Maven is using by simply executing this command in your console:
$ java -version
In the case of Windows, you just move the entry pointing to the newer Java version above the older one, like so: