简体   繁体   中英

Can't seem to get JavaFX to work with Java 10 JDK and Gradle

I have a JavaFX app that I build with Gradle and Java 8. I recently got a new laptop and installed Java 10 JDK instead of Java 8 and didn't think it'd be a big deal. However, when I try to import the Gradle project into Intellij I get this error:

org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'MyProject'

Caused by: org.gradle.api.GradleException: Couldn't find Ant-JavaFX-library, please make sure you've installed some JDK which includes JavaFX (e.g. OracleJDK or OpenJDK and OpenJFX), and JAVA_HOME is set properly.
    at de.dynamicfiles.projects.gradle.plugins.javafx.JavaFXGradlePlugin.addJavaFXAntJARToGradleBuildpath(JavaFXGradlePlugin.java:112)
More....

I have set JAVA_HOME in the Windows env vars to this path:

C:\Program Files\Java\jdk-10.0.1

How can I solve this problem?

Thanks!

Thanks for the comment feedback on this post I was able to find the problem. I first verified that the JDK 10 installation did drop off ant-javafx.jar into the lib/ dir in JAVA_HOME. It did..!

So it must be Gradle or Intellij.. right? Well there's only one super easy way to build a JavaFX gradle project at the moment and that's with javafx-gradle-plugin . Looking up the repo I can see the last release was a year ago! RED FLAG! Looking through the code I found a pathing check for a now defunct relative path that drops the verbatim error above.

So I submitted a Pull Request to the developer of the project and hopefully that resolves the issue..

That's here: https://github.com/FibreFoX/javafx-gradle-plugin/pull/128 .

In the meantime, I solved locally by copying ant-javafx.jar from it's real path at C:\\Program Files\\Java\\jdk-10.0.1\\lib\\ant-javafx.jar out into C:\\Program Files\\Java\\lib\\ant-javafx.jar . Then I rebuilt the Gradle project and everything worked accordingly, confirming the solution in the PR above.

If you're building JavaFX apps with Gradle right now, you're likely to encounter this issue until the developer fixes it. He claims he's working on a brand-new plugin right now but the last release of this widely used plugin was over a year ago.

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM