0

I read an article here and understood that there are differences between packaging JavaFX 11 and Java 11, from my project. However, I still don't know how to do it with my project.

Mine is built in Eclipse, using Maven. It is built using Java 8 JRE and JavaFX 22. I tried changing my system Java installation to Java 8, but Eclipse refused to run requiring Java 17 upwards. So, while I am still using Java 8 in development, the system java path has Java 20. I further managed to build a jar file with Eclipse, but when I run it, it tells me "... fx runtime components are missing... " I cannot package to an MSI without the jar file. What do you suggest I do in my case? My project is long overdue!

Furthermore, I am using some javafx.embed.swing.SwingFXUtils class which maven fails to compile. However, it works just fine if I run the application from Eclipse's run button. Here is a snapshot of when I do a maven build with goals: "clean install"

enter image description here

I need help to see that this project is packaged and shared this week.

Thanks in advance.

5
  • 1
    Eclipse itself requires at least Java 17 to run and most downloads include a suitable JRE built in. But you can tell Eclipse about other versions of Java in the "Installed JREs" preference and then choose one of them for your project. Commented Jul 15, 2024 at 8:03
  • 1
    The jvm Eclipse uses for itself does not have to be the same as the one your program uses. Commented Jul 15, 2024 at 13:18
  • @howlger Probably means that OP tried to run Eclipse with Java 8 but didn’t work as it requires Java 17 or later. Commented Jul 15, 2024 at 14:20
  • @ThorbjørnRavnAndersen Yes, you're right, I misread it. Deleted. Commented Jul 15, 2024 at 17:40
  • Please don't screenshot text Commented Jul 15, 2024 at 21:13

1 Answer 1

3

Minimum version of Java required for JavaFX

JavaFX 22 will not work with Java 8.

The minimum required Java runtime for JavaFX 22 is Java 17

Packaging a JavaFX application as an Windows installable application

Oracle provide a guide to package Java 22 applications into msi app installers using jpackage. Additional packaging information is in the packaging section of the JavaFX tag.

I further managed to build a jar file with Eclipse, but when I run it, it tells me "... fx runtime components are missing... " I cannot package to an MSI without the jar file.

To package using jpackage, you should package multiple jars or jmods (not a single jar file), including ones for third-party dependencies, your code, and JavaFX. If you package using the JavaFX SDK jars, you need native code for JavaFX (DLLs for Windows), in addition to the JavaFX jars (the native components are the "runtime components" mentioned in the error message you see).

Integrating JavaFX and Swing

JavaFX swing integration utilities are in the javafx.swing module which you must have on your module path and added as a module (usually by requiring java.swing in your module-info.java). If using Maven as a build tool, you must have a dependency on javafx-swing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.