1

So I've got a simple test app with a Gradle file that bundles JavaFX into the jar such that I can run "java -jar test.jar" from the terminal. It currently specifies 11.0.1 from OpenJFX. Now I can run from IntelliJ using their JBR, which has JavaFX included, but it uses some 10.0.2-internal version I don't want. Of course I could add each module manually via VM options, but ideally I have a solution that doesn't require me to do this for every configuration in all my projects. Really what I want to do is ensure the JFX versions used by IntelliJ and Gradle are the same.

I've tried adding in the JFX modules as Dependencies to my own module, adding them as Global Libraries, even adding the jar's to the SDK via classpath, but none of these solve the "JavaFX runtime components are missing" error. How can I get IntelliJ to match the version of JavaFX in my Gradle file?

enter image description here

Joseph
  • 903
  • 1
  • 10
  • 25
  • Not critical to the question, but the reason I'm attempting this is because I periodically get into situations where IntelliJ launches fine, but the resulting jar build is broken (surprise!). Pretty annoying, and I'm wondering if it could be due to the JFX version differences. – Joseph Sep 29 '20 at 17:29
  • IDE syncs the dependencies with the build file automatically or when you trigger the reimport action, see https://stackoverflow.com/a/43192764/104891. If it doesn't work, please report a bug at https://youtrack.jetbrains.com/newIssue?project=IDEA. The recommended way of packaging JavaFX with your app: https://github.com/dlemmermann/JPackageScriptFX. – CrazyCoder Sep 29 '20 at 17:39
  • Thanks, I am looking into your recommendation now. I must be misunderstanding the first part of your response, since you can see in my picture that the JFX lib's appear to be loaded as expected. I can swap consistently between the JBR (works) and the OpenJDK (doesn't). – Joseph Sep 29 '20 at 17:55
  • JDK is the external dependency that is not defined via `build.gradle`, you can't force any specific JDK location via the build configuration. If runtime components are missing in the selected JDK, it will not work. Note that JavaFX uses not only jars, but the native libraries as well. The project/system has to be configured per https://openjfx.io/openjfx-docs/#install-javafx. – CrazyCoder Sep 29 '20 at 17:58
  • Good to know about the native lib's! So it sounds like there's no way to specify a JFX version without `--module-path` and `--add-modules` (per your link) for all projects. I appreciate your help – Joseph Sep 29 '20 at 18:07

0 Answers0