1

I am attempting to run (using Maven's javafx:compile then javafx:run) the default JavaFX Application when you create a new IntelliJ project using Maven and the JavaFX archetype.

Here are the first few lines of the error, rest doesn't have any useful information:

[INFO] 
[INFO] --- javafx-maven-plugin:0.0.3:run (default-cli) @ ISAMG ---
Unrecognized option: --module-path
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    ...

Some Java configuration details:

  • The Project JDK for this project was downloaded through IntelliJ (OpenJDK).
  • Project language level is 14.
  • Module language level is 14.
  • Target bytecode is set to 14.
  • Maven's Runner JRE is set to the same project JDK (NOT through JAVA_HOME environmental variable).
  • JavaC version given in IntelliJ's terminal is javac 14.0.1
  • Java version given in IntelliJ's terminal is java version "1.8.0_261"
  • Maven itself is not installed on my computer separately from IntelliJ.
  • Project is a module project (with a module-info.java)
  • There are no plugins.

These are the steps I've tried/checked:

  1. Using javafx-maven-plugin versions 0.0.1 through 0.0.4
  2. Used a separately-downloaded copy of the JDK (from Oracle's website) and had everything point to that.
  3. Set language levels and target bytecode to 11.
  4. Tried JavaFX versions 12.0.2 and 14
  5. Tried running Maven's compile:compile then resources:resources then javafx:run. Also tried clean:clean beforehand.
  6. Tried using JAVA_HOME (for both user and system) and pointing to the separately downloaded JDK.
  7. Explicitly overrode IntelliJ's Maven Runner's pointed directory by adding an <executable>path/and/stuff</executable> pointing to JDK
  8. Git was updated to current version.
  9. Deleted everything in the .idea folder.
  10. Disabled my antivirus software
  11. Deleted and remade the .iml file in case of conflict with the pom.xml file.
  12. Overrode the target bytecode version by altering Maven's org.apache.maven.plugins configuration/release version to 14.
  13. Reinstalled Java.
  14. Restarted system after each above step.

Things of note:

  • Running the program using an Application configuration does bring up the scene correctly.
  • Running javafx:compile does not produce errors nor warnings. Nor does javafx:jlink (though this fails with a not-found error if using javafx-maven-plugin version 0.0.4).
  • During project creation there was no settings.xml for Maven so I created one based on defaults found online and placed it in the folder the error pointed to. There was a \repository folder, however.
  • I had the stated problem for a few hours, modified some things, then it changed to a Java.io.IOException: CreateProcess error=5, Access is denied error. Further changes brought be back to the original error. Steps I did were included above. Solutions provided may result in the above error coming back again.
btsai-dev
  • 175
  • 1
  • 9
  • 2
    Your `java -version` is pointing to Java 8 but the `--module-path` option was not added until Java 9. You need to make sure you're using Java 9+ (really Java 11+ since you're using JavaFX 11+) at both compile time _and_ run time. [This answer](https://stackoverflow.com/a/53129184/6395627) may help you. – Slaw Jul 16 '20 at 04:36

1 Answers1

1

Thanks to Slaw, I found the problem. I'm posting the solution in case someone else stumbles on this post when googling the problem.

Although I had everything and my JAVA_HOME set to use JDK 14 on my system, the java version still pointed to Java 8 (1.8.0_261). One of my System PATH variables was C:\ProgramData\Oracle\Java\javapath and positioned above (higher precedence) than the System PATH pointing to C:\Program Files\Java\jdk-14.0.2\bin. I simply moved the former System PATH variable all the way to the bottom of the list, and the program was able to run without any warnings or errors.

More details in Slaw's full answer here.

btsai-dev
  • 175
  • 1
  • 9