如何使用Eclipse IDE调试基于JavaFX 11的Maven项目(2019-03) [英] How to debug Maven project based on JavaFX 11 using Eclipse IDE (2019-03)

查看:132
本文介绍了如何使用Eclipse IDE调试基于JavaFX 11的Maven项目(2019-03)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:我无法使用建议的此处,并在相关问题

The problem: I am unable to debug a Maven project based on JavaFX 11 that is written and launched using Eclipse IDE 2019-03 (4.11.0) using the method suggested here and used in a related question.

示例代码:

public class HowdyJFX extends Application {

     @Override
     public void start(Stage primaryStage) throws Exception {
          final String javaVersion = System.getProperty("java.version");
          final String javafxVersion = System.getProperty("javafx.version");
          final Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
          final Scene scene = new Scene(new StackPane(l), 640, 480);
          primaryStage.setScene(scene);
          primaryStage.show();
      }

     public static void main(String[] args) {
         launch();
     }
}

如果我设置了 Eclipse在 start()方法(已分配变量)第一行的断点处,应用程序停止在那个时候运行,发生;

If I set an Eclipse breakpoint at the first line of the start() method (where a variable is assigned), the application should stop running at that point, which does not happen; instead the application continues running as if the breakpoint wasn’t there.

建议使用解决方案此处并在上面提到的问题,但它们都需要与由OpenFX建议的

A solution is suggested here and near the bottom of the question referenced above, but these both require a very different launch method than the one suggested by OpenFX.

在此先感谢任何有用的提示!

Thanks in advance for any useful tips!

推荐答案

我仍然不明白为什么人们使事情变得如此复杂。即使使用最新的JDK和JFX,通过创建运行配置来在Eclipse中运行或调试程序的旧方法仍然具有吸引力。 (我都使用15 EA)。只有两个简单的步骤。

I still don't get it why people are making things so complicated. The good old way to run or debug a program in Eclipse by just creating a run-configuration still works like a charm even with the latest JDK and JFX. (I use 15 EA for both). There are just two simple steps.

在上面的示例文件的末尾添加以下代码行。

Add the following line of code at the end of your example file above. This will allow you to completely ignore all module system nonsense.

...

class HowdyJFXLauncher {public static void main(String[] args) {HowdyJFX.main(args);}}

在Eclipse包资源管理器中选择该类,然后右键单击它。在上下文菜单中,选择调试为。在下面的选项菜单中,选择上面介绍的启动器,而不是主程序,然后单击确定。这将照常在调试器中启动程序。这适用于没有任何插件或其他内容的Maven和Non-Maven程序。如果您有module-info.java,请将其删除。在这种情况下,您可能必须重新构建项目,以便正确设置类路径。

Select the class in the Eclipse package explorer and right click on it. In the context menu select "debug as" and in the following option menu select the above introduced launcher and not the main program and then click ok. This will launch the program in the debugger as usual. This works for Maven and Non-Maven programs without any plugins or other stuff. If you have a module-info.java, remove it. You may have to rebuild your project in this case, so that the classpath gets setup correctly.

我每天都以这种方式工作,并且总是想知道为什么人们会使事情变得如此复杂。

I work this way on a daily basis and are always wondering why people are making things so complicated.

这篇关于如何使用Eclipse IDE调试基于JavaFX 11的Maven项目(2019-03)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆