简体   繁体   English

似乎无法使JavaFX与Java 10 JDK和Gradle一起使用

[英]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. 我有一个使用Gradle和Java 8构建的JavaFX应用程序。我最近买了一台新笔记本电脑,安装了Java 10 JDK而不是Java 8,因此认为这没什么大不了的。 However, when I try to import the Gradle project into Intellij I get this error: 但是,当我尝试将Gradle项目导入Intellij时,出现此错误:

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: 我在Windows环境变量中将JAVA_HOME设置为此路径:

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. 我首先验证了JDK 10的安装确实将ant-javafx.jar放到JAVA_HOME的lib / dir中。 It did..! 它做了..!

So it must be Gradle or Intellij.. right? 所以它必须是Gradle或Intellij。 Well there's only one super easy way to build a JavaFX gradle project at the moment and that's with javafx-gradle-plugin . 好吧,目前只有一种超级简单的方法来构建JavaFX gradle项目,而这就是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 . 在这里: 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 . 同时,我通过将ant-javafx.jarC:\\Program Files\\Java\\jdk-10.0.1\\lib\\ant-javafx.jar的真实路径复制到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. 然后,我重新构建了Gradle项目,并且一切工作都相应进行,确认了上面PR中的解决方案。

If you're building JavaFX apps with Gradle right now, you're likely to encounter this issue until the developer fixes it. 如果您现在正在使用Gradle构建JavaFX应用程序,则在开发人员对其进行修复之前,您可能会遇到此问题。 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! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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