JavaFX and Maven in Intellij: JAVA_HOME set but “Unrecognized option –module-path” error persisting

Tags: , , , ,

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 FilesJavajdk-12.0.1binjava.exe"</executable>) it works. I am on Windows and have set the JAVA_HOME system environment variable to C:Program FilesJavajdk-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.



<project xmlns="" xmlns:xsi=""

Other pictures:

Project language level Project outline

Environment Path

C:Program FilesMicrosoft MPIBin
C:Program FilesJavajdk-12.0.1bin
C:Program Filesapache-maven-3.6.1bin
C:Program Files (x86)Common FilesOracleJavajavapath
C:Program Files (x86)Bracketscommand
C:Program FilesGitcmd
C:Program Filesdotnet
C:Program FilesMicrosoft SQL Server130ToolsBinn
C:Program FilesPuTTY
C:Program Filesnodejs
C:Program FilesGradlegradle-5.4bin

Note also that C:Program FilesJetBrainsIntelliJ IDEA 2019.1.1bin is in user path.


For future viewers, the answer turned out to be very simple: the instructions for maven at the getting started with JavaFX are with intellij and maven (non-module version), as found here are slightly incorrect.

The instructions are as follows:

You can open the Maven Projects window and click on HelloFX -> Plugins -> compiler -> compiler:compile to compile the project, and click on HelloFX -> Plugins -> javafx -> javafx:run to execute the project.

The key part that is wrong here is that if you are using a project that uses static resources – like the FXML files in the HelloFX project – then compiling only using compiler:compile will not copy these files into the targetclasses directory.

This is a subtle mistake in the guide – presumably because if you build from command line nothing will be wrong – using mvn clean javafx:run will perform all the steps in between. Therefore, the instructions need to be to run compiler:compile and resources:resources for the thing to work in Intellij.

Alternatively, the guide could be changed to say just run javafx:compile or run the lifecycle phase called package in intellij, and then run javafx:run.

Source: stackoverflow