Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is there any way to configure a Maven-based JavaFX project so that I can import the project in (vanilla) Eclipse and debug it like other Java/Maven projects?

I am used to distribute projects with Maven and typically, everyone in the team (as well as the CI server) can rely on Maven for packing, testing, running it etc. For debugging, however, the project can be imported to Eclipse and started via a main class (as opposed to Eclipse's maven plugin). A nice example is Spring-Boot. After importing such a project, I can just run or debug the main class.

For JavaFX 11 however, this seems to work to write a pom.xml that configures all necessary dependencies, but when I import such a project to Eclipse (as Maven project), it does not configure it to the point where I could run its main class. I can run "Debug as..Maven build..", but not via the main class. I understand that it depends on platform-specific dependencies, but if it can be started vie Maven, it should be possible to start it from Eclipse without configuring Eclipse, can't it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
153 views
Welcome To Ask or Share your Answers For Others

1 Answer

I've been using Eclipse with a Maven project in exactly the way you would like to use it all the time with JFX11. It works without problems if you tweak the launch configuration correctly. Details can be found here: https://openjfx.io/openjfx-docs/

By far the easiest way to get this running is to ignore the module system and make sure that all libraries (also the JFX libraries) end up on the classpath and not the module path (which is the default if you do not have any module-info.java in your project). Then add a single line of code like this to the file with you main class.

class MyJFX11AppLauncher {public static void main(String[] args) {MyJFX11App.main(args);}}

In the Eclipse launch configuration make sure to launch your app via this new launcher class. That does the trick to run the JavaFX app without a whole flood of runtime options which you would need otherwise to get all this working. (See docs above.)

WARNING! This is not the official way to launch a JavaFX app but it works for me and I have never noticed any problem with it. Use at your own risk!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...