1

There are a lot of threads about JavaFX not being included with JDK 12/11, and that you need to have your own installation of JavaFX, but I found only this example of a modular installation without external download requirements :

https://github.com/openjfx/samples/tree/master/IDE/IntelliJ/Modular/Maven

Here is my 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>scheduler</groupId>
<artifactId>shop-solver</artifactId>
<version>1.0.0</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>

<build>
<plugins>
    <plugin>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>0.0.3</version>
        <configuration>
            <mainClass>scheduler.Main</mainClass>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
            <release>12</release>
        </configuration>
    </plugin>
</plugins>
</build>


<dependencies>
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>12</version>
</dependency>
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>12</version>
</dependency>
<dependency>
    <groupId>com.jfoenix</groupId>
    <artifactId>jfoenix</artifactId>
    <version>9.0.8</version>
</dependency>
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>27.1-jre</version>
</dependency>
<dependency>
    <groupId>org.openjdk.jmh</groupId>
    <artifactId>jmh-core</artifactId>
    <version>1.21</version>
</dependency>
<dependency>
    <groupId>org.openjdk.jmh</groupId>
    <artifactId>jmh-generator-annprocess</artifactId>
    <version>1.21</version>
</dependency>
</dependencies>

I'm still getting this error when I try to run through the javafx:run plugin : Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. Unrecognized option: --module-path

When I try to run from IntelliJ I get another error :

Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0xd5599b7) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0xd5599b7

The project worked fine under JDK1.8 and JavaFX 2, here is a video of the error happening on the upgrade : https://puu.sh/E25JW/7ecdca26d7.webm

Again, the issue is that I'm trying to build all of this modularly, I want to be able to publish a repository with maven dependencies and maybe plugin or build directives, but do not want to have people who clone my repo need to install JavaFX externally outside of Maven. Thanks.

Zee
  • 824
  • 11
  • 25
  • `Unrecognized option: --module-path` means that you are running with Java 1.8. You need to set JDK 11/12 before running `mvn javafx:run`. The second error means you are running from IntelliJ as a Java Application, and you need to add the VM arguments as documented here: https://openjfx.io/openjfx-docs/#IDE-Intellij Alternatively you could run from IntelliJ as a Maven project. – José Pereda Aug 06 '19 at 22:17
  • @JoséPereda hi, thanks a lot for your answers! https://gist.github.com/KingZee/fe2fce3329e3993cbc0e3ceefea07f4b here is the full dump just so i can make sure i am running the correct version, the pom.xml is still unedited and exactly as specified above. And the problem with VM arguments is that they require me to specify an external JavaFX installation path, I would like not to do that. – Zee Aug 06 '19 at 22:34
  • Run with `-X` to see the maven configuration, but I'd say you have Java (1.8) in your Path. Try to remove it. As an option you can use `path/to/java/12/bin/java` in the configuration. I wouldn't run as Java Application (indeed depends on local SDK), but as Maven configuration. See docs I mentioned earlier (Maven sections). – José Pereda Aug 06 '19 at 22:42
  • https://gist.github.com/KingZee/fe2fce3329e3993cbc0e3ceefea07f4b ran with -X. I also don't understand what you mean, this used to be a java application, but it is a Maven project, I followed this : https://stackoverflow.com/questions/7642456/intellij-convert-a-java-project-module-into-a-maven-project-module. Also I guess I'll try creating a completely new maven project using that tutorial now – Zee Aug 06 '19 at 22:55
  • This confirms the path issue, you are running with this: `C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe`. Try to remove it from the Windows Path. It is a Java project, indeed, but you can run it from IntelliJ as "Java application" (with java command line, regardless it is a maven project) or as Maven project with the maven plugins. – José Pereda Aug 06 '19 at 23:02
  • by the way, i tried creating a new maven project following exactly the steps mentioned, but i get an error : `[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.1.1:generate (default-cli) on project standalone-pom: The desired archetype does not exist (org.openjfx:javafx-maven-archetypes:0.0.1) -> [Help 1]` – Zee Aug 06 '19 at 23:13
  • Also, thanks! Removing the wrong java executables fom the system path "fixed" the problem, but it seems like I'm running into a new error with what might be Jfoenix EDIT: https://github.com/jfoenixadmin/JFoenix/issues/955 that does indeed look like it, I'm going to try to switch everything to jdk 11 and hopefully not mess everything up in the process. By the way you should make an answer so I can mark it as solved. – Zee Aug 06 '19 at 23:14
  • 1
    Use `javafx-archetype-fxml` archetype (as documented). – José Pereda Aug 06 '19 at 23:29

0 Answers0