1

So in my build.gradle file I have this dependencies added.

dependencies { testCompile group: 'junit', name: 'junit', version: '4.12' // https://mvnrepository.com/artifact/org.hibernate/hibernate-core compile group: 'org.hibernate', name: 'hibernate-core', version: '5.3.6.Final' // https://mvnrepository.com/artifact/mysql/mysql-connector-java compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.12' // https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0' // https://mvnrepository.com/artifact/javax.xml/jaxb-impl compile group: 'javax.xml', name: 'jaxb-impl', version: '2.1' // https://mvnrepository.com/artifact/org.openjfx/javafx-controls compile group: 'org.openjfx', name: 'javafx-controls', version: '11' } 

The class of other dependencies were added except for javafx classes. It wasn't downloaded all I get is just the meta-inf directory. I am using JDK 11, so I really need openjfx repo to use JavaFX. because in JDK 11, javafx is decoupled.

Update: I am using Intellij Idea

1 Answer 1

2

Each supported platform has its own version of JavaFx module artifacts, so you need to specify it too:

compile group: 'org.openjfx', name: 'javafx-controls', version: '11', classifier: 'linux' //'win', 'mac' 

Additionally, you will need to explicitly add all transitive dependencies of the included javafx modules, because gradle cannot resolve platform specific modules by itself:

compile group: 'org.openjfx', name: 'javafx-base', version: '11', classifier: 'linux' compile group: 'org.openjfx', name: 'javafx-graphics', version: '11', classifier: 'linux' 

Check official documentation: https://openjfx.io/openjfx-docs/#gradle

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks now its downloading the classes but I got a new error Error: JavaFX runtime components are missing, and are required to run this application
If you've followed the guide (set classpath as module path, added modules) and you're running your application directly from gradle, then it should already work. But, if you're running from IDE and not from gradle, you'll need to download JavaFx SDK (link) and change VM Options in Run Configuration manually to: --module-path="/path/to/javafx-sdk-11/lib" --add-modules=javafx.controls
Now another error occured. Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0x555e2372) 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 @0x555e2372 at com.sun.javafx.fxml.FXMLLoaderHelper.<clinit>(FXMLLoaderHelper.java:38) at javafx.fxml.FXMLLoader.<clinit>(FXMLLoader.java:2056) at com.flashery.herocafeserver.Main.<init>(Main.java:29) ... 13 more Exception running application com.flashery.herocafeserver.Main
See this line "because module javafx.graphics does not export com.sun.javafx.util"
You are using FXML, but you didn't include javafx.fxml module: --add-modules=javafx.fxml,javafx.controls.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.