且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用JDK 11/Maven/Eclipse IDE运行JavaFX应用程序

更新时间:2021-09-28 01:17:31

pom 文件中的配置正确,但是< configuration> javafx-maven-plugin 的/code>部分错误.在入门"指南和Github存储库中的资料中, mainClass 的名称为'org.openjfx.hellofx.App ,这是一个组合< groupId> 加上< artifactId> 加上简单类名.因为我项目的< groupId> < artifactId> com.spindotta.jfx11.testbed howdyjfx 我分别将它们与简单类名HowdyJFX 组合在一起.这是不正确的,因为该项目具有标准的Maven配置 source/main/java 以及***文件夹 howdyjfx .在插件中将 howdyjfx/HowdyJFX 指定为 mainClass 即可解决此问题.

The configuration in the pom file is correct, but the specification for the main class in the <configuration> section of the javafx-maven-plugin is wrong. In the both the ‘Getting started’ guide and the material on the Github repo, the name for the mainClass is ‘ org.openjfx.hellofx.App, which is a combination of the <groupId> plus <artifactId> plus the simple class name. Because the <groupId> and <artifactId> for my project are com.spindotta.jfx11.testbed and howdyjfx, respectively, I combined them with the simple class name HowdyJFX. This was incorrect because the project has the standard Maven configuration source/main/java plus a top-level folder howdyjfx. Specifying howdyjfx/HowdyJFX as the mainClass in the plugin fixed the problem.

对于价值而言,在 javafx-maven-plugin < configuration> 中指定的项目是必不可少的;省略任何内容都会产生 ERROR .应该可以在 Run配置->中指定这些值.JRE标签->VM参数,尽管我发现使用模板在 pom 中更容易处理.

For what it’s worth, the items specified in the <configuration> for the javafx-maven-plugin are essential; omitting any will generate an ERROR. It should be possible to specify these values in the Run configurations -> JRE tab -> VM arguments, although I find it easier to handle this in the pom using a template.

感谢Jose Pereda阐明了必须在运行配置中为启动指定的 Goals 问题.

Thanks to Jose Pereda for clarifying an issue with the Goals that must be specified in the Run configurations for the launch.

现在还有另一个问题.我需要能够调试入门指南中建议的方法启动的JavaFX应用程序.和 Github存储库.我在主类HowdyJFX 的第一行中设置了一个 Eclipse 断点,该行已分配了变量,这样应用程序将在该位置停止,这不会发生.而是运行应用程序,好像断点不在那里.这是与当前问题不同的问题,并且会在

Now there is another problem. I need to be able to debug JavaFX applications that are launched by the method suggested in the Getting Started guide and the Github repo. I set an Eclipse breakpoint in the main class HowdyJFX at the first line where a variable is assigned, so that the application would stop at that point, which did not happen. Instead the application ran as if the breakpoint wasn’t there. This is a different issue than the one at hand and is raised elsewhere.