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.
Sample code:
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();
}
}
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.
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!
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);}}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With