3

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

Ben
  • 199
  • 1
  • 13
  • 4
    The Debian build might not have the JavaFX modules. `java --list-modules` will list the modules in the run-time image, are there are javafx.* modules listed? – Alan Bateman Sep 22 '17 at 17:25
  • 1
    Thank you, my --list-modules did not contain javafx.* modules. It seems that I did not download the correct jdk. I got my Jdk from http://jdk.java.net/9/. This Jdk does not seem to include javafx modules. The one from the oracle site does include it, with this it is working now – Ben Sep 22 '17 at 18:02

1 Answers1

2

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.

Naman
  • 27,789
  • 26
  • 218
  • 353
  • I dont know if that matters if you just try to compile something and not execute it. Turns out I got the open-source jdk builds and they do not include javafx – Ben Sep 22 '17 at 18:07
  • *just try to compile something and not execute it* it does matter, since if the code doesn't compile it wouldn't be appropriately transformed into an executable form. Also @Ben you're welcome to update the answer with the correct link to the build you downloaded eventually and worked. that would make the answer more helpful. – Naman Sep 22 '17 at 18:09