Java 9 gradle cant find javafx module

Viewed 1623

I am trying to compile a java 9 module library with the GA Jdk 9 on an debian system with gradle 4.2. To do this, i just did this to replace my classpath with modulepath:

compileJava {
    doFirst {
        options.compilerArgs = [
            '--module-path', classpath.asPath,
        ]
        classpath = files()  
    }
}

I have all my dependent librarys in the classpath and they get into the modulepath and that is working fine, when i try to compile it does find all my own librarys.

The Problem is now that the project also uses javafx. In Java 8 jfxrt.jar was included in the jdk and was in the default classpath as far as i know. For Java 9 i red that it is now also modularized and included.

But when I try to compile the module, the compiler tells me that he cant find javafx modules:

.../src/module-info.java:10: error: module not found: javafx.controls
       requires javafx.controls;
                      ^

On Windows it works fine without javafx beeing in the modulepath

Jdk including javafx: http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html

1 Answers

The reason why the compiler can't find javafx modules on a debian system but works fine on Windows without

.../src/module-info.java:10: error: module not found: javafx.controls
       requires javafx.controls;
                  ^

is probably as listed down in the Operating Systems certification configuration. Other than confirming the list of modules using java --list-modules as suggested by @Alan in comments do make sure that :

For Linux platforms, gtk2 2.18+ is required for supporting JavaFX.


The document also states the JavaFX Graphics and Media support details if your application might be using those as well.

Related