3

At first I am a beginner in the module system of Java... I want to connect org.controlsfx.controls library to my app as module. I've created the next module-info.java in my project:

module yummy {
    requires org.controlsfx.controls;
    requires javafx.controls;
    requires javafx.fxml;

    opens com.contedevel.yummy.gui to javafx.fxml;
    opens com.contedevel.yummy.control to javafx.fxml;
    exports com.contedevel.yummy;
}

And build.gradle:

plugins {
    id 'application'
    id "org.beryx.jlink" version "2.17.5"
}

group 'com.contedevel'
version '1.0-SNAPSHOT'

application {
    mainClassName = 'com.contedevel.yummy.App'
    applicationName = 'yummy'
    applicationDefaultJvmArgs =  [
            "--add-opens=javafx.base/com.sun.javafx.runtime=org.controlsfx.controls",
            "--add-opens=javafx.base/com.sun.javafx.collections=org.controlsfx.controls",
            "--add-opens=javafx.graphics/com.sun.javafx.css=org.controlsfx.controls",
            "--add-opens=javafx.graphics/com.sun.javafx.scene=org.controlsfx.controls",
            "--add-opens=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls",
            "--add-opens=javafx.graphics/javafx.scene=org.controlsfx.controls",
            "--add-opens=javafx.controls/com.sun.javafx.scene.control=org.controlsfx.controls",
            "--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls",
            "--add-opens=javafx.controls/javafx.scene.control.skin=org.controlsfx.controls"
    ]
}

jlink {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    launcher {
        name = 'yummy'
    }
    jpackage {
        resourceDir = file("$buildDir/resources")
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation('org.controlsfx:controlsfx:11.0.1') {
        exclude group: 'org.openjfx'
    }
    compile 'org.webjars:font-awesome:5.13.0'
    testCompile 'junit:junit:4.12'
}

But when I launch my app (./gradlew run) I get the error:

yummy/src/main/java/module-info.java:2: error: module not found: org.controlsfx.controls
    requires org.controlsfx.controls;

The most interesting is IntelliJ IDEA doesn't show any errors in module-info.java.

How to connect org.controlsfx.controls as module?

P.S. I don't need to connect OpenJFX modules because I use Liberica 14 with built-in OpenJFX

Denis Sologub
  • 7,277
  • 11
  • 56
  • 123
  • 1
    I was running into so many issues with controlsfx, but when I saw you add requires org.controlsfx.controls;, I tried it out and everything is working now. Thanks! – Zac Mar 12 '21 at 13:58
  • 1
    @Zac Honestly, I gave up and switched to Qt but I am happy my question helped you) – Denis Sologub Mar 12 '21 at 20:06

0 Answers0